PDA

View Full Version : How to unsort a sorted store to original form in extjs 4?



new2extjs
26 Sep 2012, 4:31 AM
I have a store. I sort it depending upon one field and now I want to restore it to original form (the way data had been added ). Any idea how to do this?

Thanks in advance.

scottmartin
26 Sep 2012, 7:30 PM
See if this helps:



var store = Ext.create('Ext.data.Store', {
storeId : 'simpsonsStore',
fields : ['name', 'email', 'change'],
data : {'items' : [
{ 'name' : 'Lisa', 'email' : 'lisa@simpsons.com', 'change' : 100 },
{ 'name' : 'Bart', 'email' : 'bart@simpsons.com', 'change' : -20 },
{ 'name' : 'Homer', 'email' : 'home@simpsons.com', 'change' : 23 },
{ 'name' : 'Marge', 'email' : 'marge@simpsons.com', 'change' : -11 }
]},
proxy : {
type : 'memory',
reader : {
type : 'json',
root : 'items'
}
},

sorters : {
property : 'name',
direction : 'ASC'
},
});

var grid = Ext.create('Ext.grid.Panel', {
title : 'Simpsons',
store : Ext.data.StoreManager.lookup('simpsonsStore'),
columns : [
{ header : 'Name', dataIndex : 'name' },
{ header : 'Email', dataIndex : 'email', flex : 1 },
{ header : 'Change', dataIndex : 'change' }
],
height : 200,
width : 400,
renderTo : Ext.getBody()
});

setTimeout(function(){
store.sorters.clear();
store.load();
},1000);

‚Äč

Scott.

new2extjs
26 Sep 2012, 11:35 PM
Thanks a lot for the reply :)