gpt4 book ai didi

sencha-touch - Sencha Touch itemtap

转载 作者:行者123 更新时间:2023-12-04 09:37:26 27 4
gpt4 key购买 nike

我有一个 sencha touch 显示在列表中的联系人列表。然后,当您单击列表中的姓名时,它应该向右滑动并说您好 {联系人姓名}!但是当它现在滑过时,它只是说你好!第 29 行是项目点击的 Action 发生的地方,我相信问题就在这里。我只是不知道如何正确格式化它。下面是我的源代码。

ListDemo = new Ext.Application({
name: "ListDemo",

launch: function() {

ListDemo.detailPanel = new Ext.Panel({
id: 'detailpanel',
tpl: 'Hello, {firstName}!',
dockedItems: [
{
xtype: 'toolbar',
items: [{
text: 'back',
ui: 'back',
handler: function() {
ListDemo.Viewport.setActiveItem('disclosurelist', {type:'slide', direction:'right'});
}
}]
}
]
});

ListDemo.listPanel = new Ext.List({
id: 'disclosurelist',
store: ListDemo.ListStore,
itemTpl: '<div class="contact">{firstName} {lastName}</div>',

listeners:{
itemtap: function(record, index){
ListDemo.detailPanel.update(record.data);
ListDemo.Viewport.setActiveItem('detailpanel');
}
}
});

ListDemo.Viewport = new Ext.Panel ({
fullscreen: true,
layout: 'card',
cardSwitchAnimation: 'slide',
items: [ListDemo.listPanel, ListDemo.detailPanel]
});

}

});

最佳答案

传递给 itemtap 事件的第一个参数不是被点击的 List 项目的记录,而是 DataView 本身。

从文档:

itemtap : ( Ext.DataView this, Number index, Ext.Element item, Ext.EventObject e ) Fires when a node is tapped on

Listeners will be called with the following arguments:
this : Ext.DataView
The DataView object
index : Number
The index of the item that was tapped
item : Ext.Element
The item element
e : Ext.EventObject
The event object


您可以使用以下方法获取点击的记录:
dataView.store.getAt(index); // where 'dataView' is 1st argument and 'index' the 2nd

关于sencha-touch - Sencha Touch itemtap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6318382/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com