PDA

View Full Version : How to refresh a gridPanel?



mainmich
21 May 2010, 2:19 AM
Hi,

I have a gridPanel that contains data from a database.
I have a fonction to add data in the database and it work but now i'd like to refresh my gridPanel to see the new data.
I tried to re-call the function that display the grid but it display the same grid under the first one...

Romain.

Condor
21 May 2010, 2:58 AM
grid.getStore().reload();

mainmich
21 May 2010, 3:14 AM
It does not work with my grid, i don't use proxy, i take my data from the data base with java class uning DWR.

But i found a solution, i put a var gripGlobal as a global var so i can access it anywhere. Then i juste have to hide the gridGlobal and reDisplay it.

Thank you !

Animal
21 May 2010, 3:22 AM
That won't reload the data! It hides and shows a DOM element. Completely pointless.

If you have written your code correctly to use a DWRProxy, then simply grid.getStore().reload() will work.

vibhakhushi
28 May 2010, 9:35 PM
Hello Animal.. I'm a newbie in ExtJS. I am loading the grid panel using a function, not using a url. The function gets the data for me from the database. In this case, how to refresh the grid panel?

Condor
28 May 2010, 10:33 PM
Putting both the code and the data in a single page makes it impossible to do that.

Rewrite your server app to return the data on a separate url and change the store to load from that page.

After you having done this you can simply reload() the store.

vibhakhushi
30 May 2010, 10:37 PM
Thank you Condor :) Your suggestion worked for me :)

solovieff13
17 Jun 2010, 3:10 AM
Hi dudes, I have following stuff:

//process information
var proc_dataReader = new Ext.data.ArrayReader({}, [{
name: 'INSERTEDDATE',
type: 'date',
dateFormat: 'Y-m-d H:i:s'
}, {
name: 'MESSAGEKEY'
}, {
name: 'ESBCONTAINER'
}, {
name: 'ESBPROCESSNAME'
}, {
name: 'ESBPROCESSSTEP'
}, {
name: 'LOGLEVEL'
}]);
var proc_someData = [
["2004-12-01 11:12:13", "Stopped", "Container1", "1231243", "First Step", "DEBUG"],
["2004-12-01 11:12:13", "Stopped", "Container1", "1231243", "First Step", "INFO"],
["2004-12-01 11:12:13", "Stopped", "Container1", "1231243", "First Step", "ERROR"]
];
var proc_ds = new Ext.data.Store({
proxy: new Ext.data.PagingMemoryProxy(proc_someData),
remoteSort: true,
reader: proc_dataReader
});

var proc_cm = new Ext.grid.ColumnModel([{
dataIndex: 'INSERTEDDATE',
header: 'Date',
width: 60,
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s')
}, {
dataIndex: 'MESSAGEKEY',
width: 50,
header: 'Status'
}, {
dataIndex: 'ESBCONTAINER',
header: 'Container'
}, {
dataIndex: 'ESBPROCESSNAME',
header: 'Process'
}, {
dataIndex: 'ESBPROCESSSTEP',
header: 'Step'
}, {
dataIndex: 'LOGLEVEL',
header: 'Log Level'
}]);
proc_cm.defaultSortable = true;

var proc_grid = new Ext.grid.GridPanel({
id: 'act_example',
ds: proc_ds,
cm: proc_cm,
height: 200,
enableColLock: false,
loadMask: true,
viewConfig: {
forceFit: true
}, plugins: act_filters,
listeners:{
activate: function(){
proc_ds.reload();
}
},

bbar: new Ext.PagingToolbar({
store: proc_ds,
pageSize: 15,
plugins: act_filters
})
});

proc_ds.load({
params: {
start: 0,
limit: 15
}
});In another place a have a tree, I want to change data in proc_grid likethis:

click: function(n) {
//Ext.Msg.alert('Navigation Tree Click', 'You clicked: "' + n.attributes.processid + '"');
proc_someData = [
["2004-12-01 11:12:13", "AAAA", "Container1", "1231243", "First Step", "DEBUG"],
["2004-12-01 11:12:13", "AAAAAAAA", "Container1", "1231243", "First Step", "INFO"],
["2004-12-01 11:12:13", "BBBBBB", "Container1", "1231243", "First Step", "ERROR"]
];
proc_ds.reload();
proc_grid.getStore().reload();
}I have an alert on click, but nothing changes, my data is still the same. What am I doing wrong?
The problem is I can not get the data directly from URL, so I have to do some operations with it to put good objects in my grid.