List Sencha将动态点击侦听器添加到记录列表

List Sencha将动态点击侦听器添加到记录列表,list,cordova,sencha-touch,extjs,sencha-touch-2,List,Cordova,Sencha Touch,Extjs,Sencha Touch 2,我有一个Ext.data.Store和一个带有列表的Ext.Panel。 我使用以下命令动态添加记录: myStore.add({txt: r}); 我想添加一个侦听器,当我单击列表记录时,它会在消息框中显示记录数据 我怎么做 Ext.data.store var myStore = Ext.create('Ext.data.Store', { storeId: 'MyStore', fields: ['txt'] }); // create()

我有一个Ext.data.Store和一个带有列表的Ext.Panel。 我使用以下命令动态添加记录:

myStore.add({txt: r});
我想添加一个侦听器,当我单击列表记录时,它会在消息框中显示记录数据

我怎么做

Ext.data.store

   var myStore = Ext.create('Ext.data.Store', {
        storeId: 'MyStore',
        fields: ['txt']
    }); // create()
分机面板

listpanel = new Ext.Panel({
                            layout: 'fit',   // important to make layout as 'fit'
                            items: [
                                {
                                    xtype: 'titlebar',
                                    id: 'myTitle',
                                    docked: 'top',
                                    title: 'Before Change title'

                                },
                                {
                                  //Definition of the list
                                  xtype: 'list',
                                  itemTpl: '{txt}',
                                  store: myStore,
                                }]
                          });

您需要使用
Ext.List
组件的
itemtap
事件

例如


您需要使用
Ext.List
组件的
itemtap
事件

例如

   ....
   ....
   xtype: 'list',
   itemTpl: '{txt}',
   store: myStore,
   listeners : {
         itemtap : function(item, num, record, ev) {
                var myTxt = item.getStore().getAt(num).get('txt');
                Ext.Msg.alert('Message','Tapped record : '+myTxt);
         }
   }
   ....
   ....