1
我被困在sencha觸摸列表中,我需要爲列表中的行提供備用背景顏色。另一個疑問是如何在sencha touch中自定義列表,因爲我需要在列表行中添加文本字段,按鈕,圖像。我試過它與HTML和能夠做到的,有沒有什麼辦法直接添加sencha觸摸對象的項目列表。請幫助我在這個。如何訪問Sencha觸摸列表行索引,檢索值並應用更改?
我被困在sencha觸摸列表中,我需要爲列表中的行提供備用背景顏色。另一個疑問是如何在sencha touch中自定義列表,因爲我需要在列表行中添加文本字段,按鈕,圖像。我試過它與HTML和能夠做到的,有沒有什麼辦法直接添加sencha觸摸對象的項目列表。請幫助我在這個。如何訪問Sencha觸摸列表行索引,檢索值並應用更改?
您可以使用cls : 'customCls'
將添加到此組件元素的可選額外CSS類(默認爲'')。這對於使用標準CSS規則向組件或其任何子項添加自定義樣式非常有用。也許你想看看this
編輯:
Ext.regModel('Contact', {
fields: ['firstName', 'lastName']
});
var store = new Ext.data.JsonStore({
model : 'Contact',
sorters: 'lastName',
getGroupString : function(record) {
return record.get('lastName')[0];
},
data: [
{firstName: 'Tommy', lastName: 'Maintz'},
{firstName: 'Rob', lastName: 'Dougan'},
{firstName: 'Ed', lastName: 'Spencer'},
{firstName: 'Jamie', lastName: 'Avins'},
{firstName: 'Aaron', lastName: 'Conran'},
{firstName: 'Dave', lastName: 'Kaneda'},
{firstName: 'Michael', lastName: 'Mullany'},
{firstName: 'Abraham', lastName: 'Elias'},
{firstName: 'Jay', lastName: 'Robinson'}
]
});
Ext.onReady(function() {
var list = new Ext.List({
fullscreen: true,
itemTpl : '{firstName} {lastName}',
grouped : true,
indexBar: true,
store: store,
listeners: { // here you can add itemtap event and retrieve index number!
itemtap:function(item,index, e){
console.log(index);
//so, now that you have index , you can access specific item
console.log(this.store.data.items[index]);
}
},
});
list.show();
console.log(list.getStore().data.items[0]);
// here you are accessing list store and then store data and then store item with index 0
});
樣式表是好的,但是,如何讓列表索引值,並基於我們可以運用色彩索引.. – Sameer
@Sameer - 我編輯了我的答案!乾杯! –
如何在列表中添加sencha touch - 按鈕,sencha touch - 文本字段等 – Sameer