没有在itemtap sencha列表上获得记录

时间:2013-03-22 04:32:35

标签: list sencha-touch sencha-touch-2 tap

当Taping项目时,将调用侦听器但值为null。我的代码:

Ext.define('tablet.SelectCategories', {
    extend: 'Ext.navigation.View',
    xtype: 'selectcategorypanel',
    id: 'SelectCategories',
    requires:[

    ],

    initialize:function(){
       this.callParent();

       var jsonObject = Ext.create('Tablet')
           .make_webservice_call_post('get_categories');

       Ext.getCmp('select_category_list')
           .setData(jsonObject.info);

       console.log(jsonObject.info);
     },

    config: {
        //title : 'Select Categories',
        //iconCls: 'team',
        //styleHtmlContent: true,
        // scrollable: true,
        layout: {
            type: 'card'
        },

        items: [
            {
                fullscreen: true,
                mode: 'MULTI',
                xtype: 'list',
                itemTpl: '{name}',
                autoLoad: true,
                id:'select_category_list',
                store: {
                    fields: ['active','created','description','name']
                },
                listeners: {
                    itemtap: function (list, records) {
                        console.log('Sel');
                        console.log(records.name);
                        var names = [];
                        Ext.Array.each(records, function (item) {
                            names.push('<li>' + item.data.name + '</li>');
                        }); // each()
                        Ext.Msg.alert('You selected ' + records.length + ' item(s)',
                             '<ul>' + names.join('') + '</ul>');
                    } // selectionchange
                }

                // handler:self.itemClick         
            }

在console.log(records.name)中获取未定义;

1 个答案:

答案 0 :(得分:1)

itemtap的方法签名也是错误的。它应该是 -

itemtap: function(list, index, target, record) {
    console.log('Item tapped');
    console.log(record.get('name'));

    // and your rest of the code.
}

查看itemtap活动here的文档,并阅读有关商店here的更多信息。