PDA

View Full Version : problem with refresh (reload) dynamic grid



andryi
19 Nov 2009, 4:11 PM
hi all, I've got a problem how can I reload a dynamic grid, because when I run for first time, all works, and it's ok, and so , this grid is in a panel with a button, so when I clicked the button appears a form with data from the grid and I change the data and close the form, the problem is when I close the form, the data in the grid no refresing,, I try with this,


callsGrid.getStore().removeAll();
callsStore.load({params: {start:'0',limit:10}});
callsGrid.getView().refresh();


but not works,
so can anybody help me please??

sancho_0
19 Nov 2009, 6:34 PM
Hey,

What do you mean with: "but not works" ?? are you using firebug? what do you see? any request to the server? any js error? If you provide more information, it will be easier to help you.

May be I'm loosing something here... but did you try this?:


callsGrid.getStore().reload();

If you want to reload the store, just do it... :)

Best Regards

genio
20 Nov 2009, 2:05 AM
What is callsStore??

I would do this;



callsGrid.getStore().removeAll();
callsGrid.getStore().getStore().baseParams = {start:'0',limit:10};
callsGrid.getStore().load();


Not sure if you actually even need callsGrid.getView().refresh()

mankz
20 Nov 2009, 2:07 AM
callsGrid.getStore().removeAll(); // Not necessary
callsGrid.getStore().getStore().baseParams = {start:'0',limit:10};
callsGrid.getStore().load();

Don't do


callsGrid.getView().refresh();

andryi
20 Nov 2009, 7:06 AM
:D, thank's to all, and specially to sancho, I put only the sentence



callsGrid.getStore().reload();


and works good :D, thank's men

CrazyEnigma
20 Nov 2009, 9:31 AM
Are you interested in using the PagingToolbar, because that what it seems you are trying to accomplish.




var storeConfig= {
url: yourURL,
method: 'POST',
reader: new Ext.data.ArrayReader({
totalProperty: 'count',
root: 'rows',
idProperty: 'id',
fields: // Your field contract
}),
autoDestroy: true,
remoteSort: true,
baseParams: {
// Anything that you require outside of start, limit, sort, dir because that will be fed by the PagingToolbar.
}
};

var yourStore = new Ext.data.Store(storeConfig);

new Ext.grid.GridPanel({
// ...
store: yourStore,
tbar: new Ext.PagingToolbar({
store: yourStore,
displayInfo: true,
pageSize: 10,
displayMsg: 'Records {0} - {1} of {2}',
emptyMsg: 'No records available'
},
// ...
listeners: {
resize: { // When the grid resizes, the pageSize will change. This will hit two to three times when the page resizes initially.
fn: function(scope, adjWidth, adjHeight, rawWidth, rawHeight) {
var toolbar = scope.getTopToolbar();
// Calculate paging size
var newPageSize = Math.floor(adjHeight / 25) - 1;
var activePage = Math.ceil((toolbar.cursor + 1) / newPageSize);
toolbar.pageSize = newPageSize;
toolbar.changePage(activePage);
}
}
};



Of course, your backend has to understand sort and dir as well to take advantage of the sort.