Question

When Taping items the listener is getting invoked but the value is null. My Code:

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         
            }

Getting undefined in console.log(records.name);

Was it helpful?

Solution

Your method signature for itemtap is also wrong. It should be -

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

    // and your rest of the code.
}

Check the documentation for the itemtap event here, and read up more about stores here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top