javascript - 如何对 ArrayStore 进行排序?

标签 javascript extjs extjs4

我有一个对象:

   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/

相关文章:

EXTJS4-如何实现搜索框

javascript - Web 应用程序有意义的目录结构

面板内的 extjs gridpanel 不自动滚动或调整大小

javascript - 使用 gulp 构建 extjs

javascript - 如何在没有 NavigationView 的情况下处理 sencha 触摸应用程序中的后退按钮?

extjs - 如何在 extjs4 中的特定事件调用上动态加载 Controller ?

javascript - "node -r package.json"- 如何访问内部对象?

javascript - 我如何在 jsfiddle 中使用 LESS?

javascript - 如何解释 Observable.of(Math.random()) 总是返回相同的值?

extjs - extjs 数据 View 中的搜索字段