質問

に問題がありました Dataview. 。 Dataview レンダリングするアイテムにリスナーが必要です。

だからここに私の方法があります Dataview 見た目:

var childrenData = Ext.create('Ext.DataView', {
    store: {
        fields: ['id', 'name', 'children'],
        proxy: {
            type: 'ajax',
            url: '/category/view',
            reader: {
                type: 'json',
            }
        },
        autoLoad: true,
    },
    itemTpl: childrenTemplate,
    listeners: {
             itemtap: function(data,index){
                    var record = data.getStore().getAt(index);
                console.log(record);
          }
    }
});

誰かが、なぜこれがうまくいかないのか考えていますか?

編集:テンプレートの追加データ:var Childrentemplate = new ext.xtemplate( '' '、' '、' '、' {name} '、' ''、 ''、 '{rice}'、 ''、 ''、 ''、 '');

役に立ちましたか?

解決 2

私は問題が何であるかを知りました。

DataViewは、Tabpanelにある容器にありました。

いくつかの試行錯誤の後、コンテナをXTypeの構成オブジェクトとして定義すると、「コンテナ」が機能することがわかりました。 ext.create( 'ext.container'、{})の上にコンテナを作成した場合。どういうわけかうまくいきません。すでにSenchaフォーラムでバグか機能かを尋ねられたので、更新し続けます。

他のヒント

以下のコードを試してください。 (Sencha-Touch-2の場合)

var childrenData = Ext.create('Ext.DataView', {
        store: {
            fields: ['id', 'name', 'children'],
            proxy: {
                type: 'ajax',
                url: '/category/view',
                reader: {
                    type: 'json',
                }
            },
            autoLoad: true,
        },
        itemTpl: childrenTemplate
    });

リスナーを追加します。

childrenData.on({
      tap: function(data,index){
              var record = data.getStore().getAt(index);
              console.log(record);
         }
});
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top