[英]Sorting list Sencha Touch
I have used the example code from "Intro to List Components". 我使用了“组件简介”中的示例代码。 I was able to successfully run it on a android simulator.
我能够在android模拟器上成功运行它。 Now I want to sort it by firstName rather the lastName.
现在,我想按firstName而不是lastName对其进行排序。 When I changed to sorters: "lastName" to firstName, I can see that the Index bar is not in alphabetical order.
当我将排序器从“ lastName”更改为firstName时,可以看到索引栏不是按字母顺序排列的。 How can I sort by firstName with proper index order?
如何按具有正确索引顺序的firstName排序?
Ext.regModel('Contact', {
fields: ['firstName', 'lastName']
});
ListDemo.ListStore = new Ext.data.Store({
model: 'Contact',
sorters: 'firstName',
getGroupString : function(record) {
return record.get('lastName')[0];
},
data: [
{ firstName: "Domino", lastName: "Derval" },
{ firstName: "Elektra", lastName: "King" },
{ firstName: "Fiona", lastName: "Volpe" },
{ firstName: "Holly", lastName: "Goodhead" },
]
});
change this line: 更改此行:
getGroupString : function(record) {
return record.get('lastName')[0];
},
to: 至:
getGroupString : function(record) {
return record.get('firstName')[0];
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.