1
我正在嘗試使用Ext.dataview.component.ListItem
在sencha touch 2.3
(使用sencha架構師)中創建列表。我能夠通過使用updateRecord
方法從商店中獲取值,但是我無法將其傳回主要組件。Sencha 2.3中使用架構師的DataView組件列表項
這就是我想實現: -
我想創建其文本將被從商店的動態顯示,如果用戶點擊它,它應該表現出與年齡報警按鈕的列表。我有一個名字和年齡的商店。我能夠得到的名字,但我不能得到警報setup.I需要用但─ 幫助這裏是我的數據視圖類
Ext.define('MyListItem.view.MyListItem', {
extend: 'Ext.dataview.component.ListItem',
alias: 'widget.mylistitem',
requires: [
'Ext.Button',
'Ext.MessageBox'
],
config: {
padding: 10,
layout: 'hbox',
items: [
{
xtype: 'button',
handler: function(button, e) {
var record = this.getRecord();
console.log("buttonTapped");
console.log(record);
Ext.Msg.alert(
record.get('name'), // the title of the alert
"The age of this person is: " + record.get('age') // the message of the alert
);
},
text: 'MyButton'
},
{
xtype: 'component',
flex: 1,
html: 'Sample component inside dataitem'
}
]
},
updateRecord: function(record) {
// Provide an implementation to update this container's child items
var me = this;
me.down('button').setText(record.get('name'));
}
});
這裏是我的商店: -
Ext.define('MyListItem.store.MyDirectStore', {
extend: 'Ext.data.Store',
requires: [
'MyListItem.model.MyModel'
],
config: {
data: [
{
name: 'Adam',
age: '28'
},
{
name: 'Eve',
age: '27'
}
],
model: 'MyListItem.model.MyModel',
storeId: 'MyDirectStore'
}
});
謝謝阿努比斯。這幫助我 – Kapil
@Anubis,你可以看看我的sencha觸摸問題描述[這裏](http://stackoverflow.com/questions/22457136/sencha-touch-with-phonegap-using-sencha-cmd-and -phonegap-build-causes-error)?會很感激。 – codin