我有一个对象:
store: Ext.create('Ext.data.ArrayStore',{
sortInfo: { field: "uniq_users", direction: "DESC" },
fields: [
{name: 'Country', type: 'string'},
{name: 'uniq_users', type:'int'}],
data: [{Country: 'Ed', users: 'Spencer'}]
})
store.loadData(...)
为什么默认排序对字段不起作用?
最佳答案
sortInfo
属性可用于 ExtJS 3.x 而不是最新版本。随着版本 4 的发布,排序是通过 mixin Ext.util.Sortable
实现的。您应该使用属性 sorters
来定义您的排序参数。
这是你应该做的:
store: Ext.create('Ext.data.ArrayStore',{
sorters: [
{property : 'uniq_users',direction: 'DESC'}
],
fields: [
{name: 'Country', type: 'string'},
{name: 'uniq_users', type:'int'}
],
data: [{Country: 'Ed', users: 'Spencer'}]
});
store.loadData(...);
关于javascript - 如何对 ArrayStore 进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8592618/