排序sencha touch数据视图列表

时间:2013-06-19 20:17:59

标签: sencha-touch-2

我有一个Ext.dataview.List链接到按日期DESC排序的商店。

当我运行应用程序时,列表的顺序是正确的日期。

当我添加新项目时,它总是被添加到列表的底部而不是正确的排序顺序。当我刷新应用程序时,订单再次正确排序。

我在列表中添加了一个项目:

var myStore = Ext.getStore('myStore');
myStore.add(model);
myStore.sync();

查看:

Ext.create('Ext.dataview.List', {
    fullscreen: true,
    itemTpl: '{title}',
    store: Ext.getStore('myStore')
});

如何将商品添加到商店并获取列表以对商品进行排序,以便商品位于正确的位置?

2 个答案:

答案 0 :(得分:2)

我尝试使用:

myStore.sort();
myStore.sort('date', 'DESC');

他们没有用。这解决了这个问题:

myStore.data.sort()

答案 1 :(得分:0)

添加模型后,您必须手动对商店进行排序。试试这个:

var myStore = Ext.getStore('myStore');
myStore.add(model);
myStore.sync();
//Also note that the sync() method is only when you're using a localStorage proxy

myStore.sort();

myStore.sort('date', 'DESC');
相关问题