0
我想不通我怎麼能在商店(ID號碼)檢索給定數據項將其發送到一個監聽器「setActiveItem」的方法: 所以我有一個店 - 型號:如何通過Sencha touch中的停靠菜單列表中的菜單項在轉盤中選擇卡片?
Ext.regModel('PictureItem', {
fields: ['id', 'titel', 'url']
});
var pictureItems = new Ext.data.Store({
model: 'PictureItem',
data: [
{id:1, titel:'page 1', url:'http://placekitten.com/1024/768'},
{id:2, titel:'page 2', url:'http://placekitten.com/1024/768'},
{id:3, titel:'page 3', url:'http://placekitten.com/1024/768'},
]
});
這裏是我的菜單列表稱爲 「leftList」:
var leftList = new Ext.List({
dock: 'left',
id:'list1',
width: 135,
overlay: true,
itemTpl: '{titel}',
singleSelect: true,
defaults: {
cls: 'pic'
},
store: pictureItems,
listeners:{
selectionchange: function (model, records) {
if (records[0]) {
Ext.getCmp('karte').setActiveItem(!!!Here the number of the selected Item
or respondend "id" in the data store!!!);
}
}
}
});
和傳送帶....
var carousel = new Ext.Carousel({
id: 'karte',
defaults: {
cls: 'card'
},
items: [{
scroll: 'vertical',
title: 'Tab 1',
html: '<img class="orientation" alt="" src="img_winkel/titel_v.jpg">'
},
如果我打電話
Ext.getCmp('karte').setActiveItem(2);
它與被叫卡一起工作 - 但是我怎樣才能從菜單列表/存儲中選擇的項目的ID號碼? 順便說一下:是什麼意思:
if(records [0]){ why [0]?
'if(records [0])''是因爲記錄總是一個數組,即使它是單個項目,所以檢查記錄[0]只是爲了確保至少有一個項目選擇..至於你的其他問題全部我會說是你想要的信息是在記錄[0] .data ..你不能「setActiveTarget」它,因爲它不是你的傳送帶容器中的項目.. – chrixian