0

JSONストアがあります:

var jsonstore = new Ext.data.ArrayStore({
    fields: ['bla', 'blubb'],
    data: [ ['bla', 'blubb'],
            ['blabla', 'blublu'],
            ['blass', 'hallo'],
            ['bam', 'guckt'] ]
});

および extjs リストビュー:

....
,{
       xtype: 'listview',
       name: 'abrufliste',
       store: jsonstore,
       id:"ladebereich",
       multiSelect: false,
       emptyText: 'nix da',
       reserveScrollOffset: true,
       columns: [ { header: 'Name',
                    width: .5,
                    dataIndex: 'NAME' } 
....

そしてクリックイベント:

Ext.ComponentMgr.get('ladebereich').on("click",function (sthis,index,node,e ){ 
    alert("node:  "+node.childNodes[0].childNodes[0].innerHTML);});

クリックしたノードの値を取得したい。

私は値を取得します

node.childNodes[0].childNodes[0].innerHTML

、しかし、それはくだらない解決策です。

jsonstore からクリックした要素を取得したいのですが、何か提案はありますか?

4

2 に答える 2

1

もう1つの方法は、リストビューにリスナーを追加して、リストビューのクリックイベントに応答することです。

,{
   xtype: 'listview',
   name: 'abrufliste',
   store: jsonstore,
   id:"ladebereich",
   multiSelect: false,
   emptyText: 'nix da',
   reserveScrollOffset: true,

   listeners:
   {
       click: function(object, selectedIndex, node, event) {
           // Get the name corresponding to the selected row.
           var rowName = object.store.getAt(selectedIndex).get("Name");
       }
   },

   columns: [ { header: 'Name',
                width: .5,
                dataIndex: 'NAME' } 
于 2010-02-19T23:20:47.513 に答える
0

それは動作します

Ext.ComponentMgr.get('ladebereich').on("click",function (sthis,index,node,e ){

    var rec = jsonstore.getAt(index);
    alert(rec.get("NAME"));
});
于 2010-02-15T14:45:19.030 に答える