0
votes

I have following Sencha Touch code. A simple list view.

{
            xtype: 'list',
            itemId: 'stockitemslist',
            ui: 'normal',
            flex: 1,
            onItemDisclosure: false,
            preventSelectionOnDisclose: false,
            itemTpl: '<div class="act-list">'+
                '<table width="100%">'+
                '<tr>'+
                '<td  width="10%"><img align="left" src="img/icon_check2.png"/></td>'+
                '<td  width="80%"><b>&nbsp; {MaterialDesc}</b></td>'+
                //'<td  width="10%" ><img align="right" src="img/icon_list_disclosure.png"/></td>'+
                '</tr>'+
                '</table>'+
                '</div>'
        }

I want to set an alert once click an item of the list view. In my controller I tried following.

Ext.define('net.omobio.dialog.dialogcc.controller.StockAvailability', {
extend: 'Ext.app.Controller',
/*requires: [
    'net.omobio.dialog.dialogcc.store.StockItems'],*/
config: {
    refs: {
        maincard: 'stockitemsmain #cardview',
        StockItems: 'Stock_items',
        StockItemList: 'Stock_items #stockitemslist'

    },

    control: {
        'StockItemList': {
            itemtap: 'onStockItemlistTap'
        }
    },

    routes: {
        'bucketlist': 'loadbucketlist'
    },

    onStockItemlistTap: function(list, index, target, record, event) {
        console.log('Item was tapped on the Data View');
        console.log(list, index, target, record, event);
        Ext.Msg.alert('', 'The material code selected is: ' + record.get('MaterialCode'));
        var me = this;
        console.log('record');
        console.log(record);
        console.log('index');
        console.log(index);

    },

    loadbucketlist: function() {
        console.log('xxxx Bucket List');
        //this.showView('docrecoverydsr.ConnectionList');

    }

}

});

But once I click an item it gives following error.

Uncaught TypeError: Cannot read property 'apply' of undefined

Any suggestions would be appreciated.

1

1 Answers

0
votes

Please try below code

Ext.define('net.omobio.dialog.dialogcc.controller.StockAvailability', {
    extend: 'Ext.app.Controller',
   /*requires: [
            'net.omobio.dialog.dialogcc.store.StockItems'],*/
   config: {
     refs: {
        maincard: 'stockitemsmain #cardview',
        StockItems: 'Stock_items',
        StockItemList: 'Stock_items #stockitemslist'

      },

      control: {
        StockItemList: {
            itemtap: 'onStockItemlistTap'
        }
      },

     routes: {
        'bucketlist': 'loadbucketlist'
     }
    },

    onStockItemlistTap: function(list, index, target, record, event) {
        console.log('Item was tapped on the Data View');
        console.log(list, index, target, record, event);
        Ext.Msg.alert('', 'The material code selected is: ' + record.get('MaterialCode'));
        var me = this;
        console.log('record');
        console.log(record);
        console.log('index');
        console.log(index);

    },

    loadbucketlist: function() {
        console.log('xxxx Bucket List');
        //this.showView('docrecoverydsr.ConnectionList');

    }



});