0

我已经定义了一个煎茶列表如下

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
                            }
                        }
                    }
                });

列表的项目是动态添加的,它们没有“id”。我想在上面的列表中触发(第一项)itemtap 事件。我怎样才能做到这一点?

4

2 回答 2

0
 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);


    }
}

这可能会帮助你

于 2012-04-09T06:05:11.277 回答
0

这应该允许您获取选定的记录并触发该点击事件

  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);


        }
    }
于 2012-04-04T20:49:36.873 回答