PDA

View Full Version : Can you refresh paging toolbar without firing load?



kathy_s
6 Mar 2012, 12:52 AM
Hi,

I have the following problem:
After inserting a record I need to load the correct page to be able to select the newly created record.
I implemented a load function in my webservice that accepts a recordid, to be able to calculate with the pagesize and orderby info what block of records I have to return.
The response contains the pagenumber.
With the following code I load the records after the insert:


g_modelStore.load({
id : id,
scope : this,
callback: function(records, operation, success) {
var loadJson = Ext.decode(operation.response.responseText);
g_modelStore.currentPage = parseInt(loadJson.result.message);

// g_modelGrid.down('sds_pagingtoolbar').doRefresh(); This updates the
pagingtoolbar correctly, but I don't want to fire another server call

enableGrids();
g_modelEditWindow.hide();
g_modelGrid.getSelectionModel().select(g_modelStore.getById(id));
}
});


Is there a way to update the paging info in the pagingtoolbar without loading the records again?

Thanks for any tips.

friend
6 Mar 2012, 5:20 AM
There's no built-in/convenient way to do this, but it can be done.

View source for the Ext.toolbar.Paging component and look for the getPagingItems function. This is where the child component list is built. Every component on the toolbar has an itemId value which can be used to directly access the desired button, page number input field, etc.

For example, to directly set the page number:



myPagingTbar.down('#inputItem').setValue(99);


To directly set the 'Displaying n - n of n' message:



myPagingTbar.down('#displayItem').update(Ext.String.format(myPagingTbar.displayMsg, 1, 2, 3));

kathy_s
6 Mar 2012, 12:25 PM
Works perfectly! Thanks a lot!