简体   繁体   English

在 Ext.List 上触发 itemtap 事件

[英]firing itemtap event on Ext.List

I have defined a sencha List as below我定义了一个煎茶列表如下

Ext.List({
                    itemTpl: '<div class={filterClass}></div>{filterType}',
                    id: 'sFilter',
                    width: 200,
                    cls: 'sFilter',
                    grouped: false,
                    indexBar: false,
                    store: store,
                    listeners: {
                        itemtap: function (me, index, item, e) {
                            var selectedRecord = me.store.getAt(index);
                            var filterTag = selectedRecord.data.filterTag;
                            if (filterTag !== searchResultTag.Everything) {
                                var filteredResults = filterResults(filterTag, allResults);
                                //some more code
                            } else {
                                //some more code
                            }
                        }
                    }
                });

Items of the list are dynamically added and they dont have an "id".列表项是动态添加的,它们没有“id”。 I would like to fire (first item) itemtap event on the above list.我想在上面的列表中触发(第一项)itemtap 事件。 How can I do that?我怎样才能做到这一点?

This should allow you to grab the selected record and fire that tap event这应该允许您获取选定的记录并触发该点击事件

  listeners: {
            itemtap: function (me, record, index, item, e) {
                var selectedRecord = index.data.filterType;
                var rec=record;

                if(rec===0){
                    alert('This is the first record');
                }else{
                    alert('This is not the first record')
                }
                       alert(selectedRecord);


        }
    }
 listeners: {
        itemtap: function (me, index, item,record,e) {


            if(index==0){
                alert('This is the first record');
            }else{
                alert('This is not the first record')
            }
                   alert(selectedRecord);


    }
}

this may help you这可能对你有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM