PDA

View Full Version : PagedGridView extended (check after load missing page)



Sasha
29 Jan 2007, 4:01 AM
Hi, Jack.

I have written check for missing page after load. Maybe you will include it in your library.

Source of overrided method (onPageLoaded of the PagedGridView class):


YAHOO.override(YAHOO.ext.grid.PagedGridView, {
onPageLoaded : function(pageNum, totalPages){

// BEGIN: Small check added
if (pageNum > totalPages) {
this.grid.dataModel.loadPage(totalPages);
return;
}
// END: Small check added

this.cursor = pageNum;
this.lastPage = totalPages;
this.afterTextEl.innerHTML = this.afterPageText.replace('%0', totalPages);
this.field.dom.value = pageNum;
this.first.setDisabled(pageNum == 1);
this.prev.setDisabled(pageNum == 1);
this.next.setDisabled(pageNum == totalPages);
this.last.setDisabled(pageNum == totalPages);
this.loading.enable();
},
});


Problem:
For example, we have 3 pages. User goes from 1st to 2nd. All fine until number of pages are changed.
If number of pages after last datamodel refreshing has been reduced (2 pages) and user has went to the last page (3rd page) he will see the empty grid with "Page 3 of 2" text in the bottom of PagedGridView.

I have written possible solution above.