getting index value 0 from dataview any list itemtap from sencha touch

后端 未结 2 1777
误落风尘
误落风尘 2021-01-23 14:53

I am unable to get index value form the dataview:

    {          
              xtype: \'list\', 
              itemId: \'catList\',
              store: \'Categ         


        
2条回答
  •  不要未来只要你来
    2021-01-23 15:39

    I don't really know what's wrong with your code as I tested it and it worked fine. However, a few things are wrong.

    • You do not need the for loop in your itemTpl as "itemTpl" is already iterating in you data array for you. You would need it if you were using just "tpl".
    • Avoid to have your listeners in your view. Instead, get a reference to your list in your controller, and set the listeners there. This is bad practise and it breaks the NVC pattern.

    Here is a small version that works on my te4st application:

    {
        xtype: 'list', 
        itemId: 'catList',
        scrollable: false,
        data: [
            { category_name: 'A', cat_id: 1},
            { category_name: 'B', cat_id: 2},
            { category_name: 'C', cat_id: 3},
            { category_name: 'D', cat_id: 4},
            { category_name: 'E', cat_id: 5},
        ],
        loadingText: "Loading Words...",
        emptyText: '
    {message}
    ', autoLoad:true, itemTpl: '{category_name}', listeners: { 'itemtap': function(list, index, target, record, e, eOpts){ //TODO: whatever.. } } }

提交回复
热议问题