View Full Version : how to add a default record to gridl panel with paging Toolbar?

27 Jun 2013, 1:05 AM
hi all,
I have a grid (ajax proxy) with paging toolbar and I would insert a default record in that grid everytime after the store load. My problem is when store is empty after load, the paging toolBar will show "Page [1] of 0". (should be Page [1] of 1, because i sneak in a default record)

Is there a way to insert a record after the store load and before paging toolbar update with the store?
or can i set a default page value to 1 for the paging toolbar?
or other other ways to solve my problem?

thanks for reading :)

27 Jun 2013, 1:09 AM
I found this override on some forums while searching for the same problem some months back:

Override to get paging toolbar to say 1 of 1 pages when store is empty and
thus also disable the next and end buttons. Otherwise, the next and end buttons
are enabled and 1 of 0 pages is displayed
Ext.override(Ext.toolbar.Paging, {
getPageData : function()
var store = this.store,
totalCount = store.getTotalCount();
if(totalCount === 0)
totalCount = 1 ;

return {
total : totalCount,
currentPage : store.currentPage,
pageCount: Math.ceil(totalCount / store.pageSize),
fromRecord: ((store.currentPage - 1) * store.pageSize) + 1,
toRecord: Math.min(store.currentPage * store.pageSize, totalCount)

27 Jun 2013, 4:52 AM
problem solved. thank you!! :D:D:D:D:D