1

当 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) 中获取未定义;

4

1 回答 1

1

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

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

    // and your rest of the code.
}

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

于 2013-03-22T06:12:42.777 回答