PDA

View Full Version : [2.0b1a][SOLVED] Grid loads data twice



madrabaz
15 Oct 2007, 5:14 AM
(Window XP ,Firefox 2.0.0.7) I did not check this issue another browser or OS.

I create a grid which uses the following data store configuration.


var ds = new Ext.data.JsonStore({
method : 'POST',
autoLoad : true,
url: './user/index/get',
successProperty : 'success',
root: 'data',
totalProperty : 'total',
id : 'ID',
remoteSort : true,
sortInfo : {field: "NAME", direction: "ASC"},
fields: ['ID', 'NAME', 'SURNAME', 'EMAIL']
});

The problem is the grid loads data twice when

autoLoad is true,
remoteSort is true,
and there is a grid sort state in the cookie.


GridPanel applyState method calls GridPanel.store.sort (ds.sort) method when it finds sort state


if(state.sort){
this.store.sort(state.sort.field, state.sort.direction);
}

so GridPanel.store.sort(ds.sort) calls again GridPanel.store.load(ds.load) method because remoteSort is true.

I hope that I can explain the problem.

mystix
15 Oct 2007, 5:26 AM
hi madrabaz,

are you using Ext 2.0a1 / 2.0b1a?

madrabaz
15 Oct 2007, 6:17 AM
I am using 2.0b1a but the problem also occured on 2.0a1

hendricd
15 Oct 2007, 8:27 AM
I believe you want:


if(state.sort){
this.store.setDefaultSort(state.sort.field, state.sort.direction);
}

jack.slocum
15 Oct 2007, 11:58 AM
Thanks guys, this is what I changed it to:


if(state.sort){
this.store[this.store.remoteSort ? 'setDefaultSort' : 'sort'](state.sort.field, state.sort.direction);
}