Reputation: 1627
I have a Ext.dataview.List that is linked to a store that is sorted by date DESC.
When I run the app the list is in the correct date sorted order.
When I add a new item it always gets added to the bottom of the list rather than in the correct sorted order. When I refresh the app the order is sorted correctly again.
I am adding an item to the list:
var myStore = Ext.getStore('myStore');
myStore.add(model);
myStore.sync();
View:
Ext.create('Ext.dataview.List', {
fullscreen: true,
itemTpl: '{title}',
store: Ext.getStore('myStore')
});
How do I add an item to the store and get the list to sort itself so that the item is in the correct place?
Upvotes: 0
Views: 1457
Reputation: 1627
I tried using:
myStore.sort();
myStore.sort('date', 'DESC');
They did not work. This fixed the issue though:
myStore.data.sort()
Upvotes: 2
Reputation: 4947
You have to manually sort the store after adding the model. Try this:
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();
or
myStore.sort('date', 'DESC');
Upvotes: 0