PDA

View Full Version : Is it possible to reload a grid component?



marxan
23 Nov 2010, 11:59 PM
Hi,

I'm using the pagingtoolbar component which works fine until I reload the store with new data.

What I do, I have a combobox, when I select a value a reload the store by passing it new parameters.
The store is correct with new datas but when I click on a button of the pagingtoolbar (refresh for instance)
It reloads my store with the previous parameters. So I wonder if I should also reload the grid in order to give the good parameters to component.

Here is a part of my datagrid Code and his store.

var myPageSize = 8;
var store = new Ext.data.JsonStore({
totalProperty: 'DATASET',
root: 'ROWS',
url: '../components/JSONProject.cfc',
remoteSort: true,
baseParams:
{
method: 'GetProjectDetail',
returnFormat: 'JSON',
phase: this.phase,
directorate: this.directorate,
unit: this.unit
},
reader: ProjectReader,
/*autoLoad:{
params:{
phase: this.phase,
directorate: this.directorate,
unit: this.unit
}*/
//},
fields:[
'FP',
'Call',
'Dir',
'Unit',
'Project',
'Acronym',
'PO',
'CurrentStep',
'Period',
'GrossElapseTime',
'ClockElapseTime',
'ClockState'
]
});

var config = {
store: store,
height:255,
title: 'Project Current Status',
titleCollapse: true,
collapsible: true,
loadMask: true,
bbar: new Ext.PagingToolbar({
pageSize: 8,
store: store,
displayInfo: true,
displayMsg: 'Displaying projects {0} - {1} of {2}',
emptyMsg: 'No project to display'}),
Here is the action to reload my store.

var projectCurrentStatus = Ext.getCmp('projectCurrentStatus');
projectCurrentStatus.store.removeAll();
projectCurrentStatus.store.reload({
params: {phase:phase,directorate:directorate,unit:unit}
});Any help would be appreciated.

Marxan

Condor
24 Nov 2010, 12:27 AM
With paging you have to put the extra parameters in baseParams and load the store only with start and limit params.

var store = Ext.getCmp('projectCurrentStatus').getStore();
store.removeAll();
store.baseParams = {
phase: phase,
directorate: directorate,
unit: unit
};
store.load({
params: {
start: 0,
limit: 8
}
});

marxan
24 Nov 2010, 12:59 AM
With paging you have to put the extra parameters in baseParams and load the store only with start and limit params.

var store = Ext.getCmp('projectCurrentStatus').getStore();
store.removeAll();
store.baseParams = {
phase: phase,
directorate: directorate,
unit: unit
};
store.load({
params: {
start: 0,
limit: 8
}
});
Thanks for your answer Condor but when I use the store.baseParams, There are no data anymore in the grid when I do a reload.
In firebug, instead of a post, there is a get CFIDE/componentsutils/cfexplorer.cfc/... This is because my baseParams but no idea why it doesn't do a post like the others...

Condor
24 Nov 2010, 1:15 AM
I see you are already using baseParams, so assigning new baseParams would remove method and returnFormat.

Instead use:

Ext.apply(store.baseParams, {
phase: phase,
directorate: directorate,
unit: unit
});

marxan
24 Nov 2010, 1:53 AM
I see you are already using baseParams, so assigning new baseParams would remove method and returnFormat.

Instead use:

Ext.apply(store.baseParams, {
phase: phase,
directorate: directorate,
unit: unit
});


Once again you give me the solution Condor!
Thanks a lot! If I decide to believe in a religion, you will be my god ;-)