This is a migrated thread and some comments may be shown as answers.

PageCountChanged event?

1 Answer 41 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bent
Top achievements
Rank 2
Bent asked on 18 Nov 2008, 03:08 PM
Hi there

Whenever I modify the query with my RadGrid, I might get into a situation where the current page the user is viewing is no longer there (ie. page 15 out of 10).

I currently perform a check in the RadGrid's PreRender event, to see it the actual PageIndex+1 is higher that the PageCount, in which case I set the new PageIndex to 0 (or PageCount-1 depending on what I am trying to achieve). This however seems a bit like a hack, and I would appreciate some other, more elegant solution.

The first thing that popped into my mind was a PageCountChanged event perhaps? We already have PageIndexChanged and PageSizeChanged, but not PageCountChanged.

Any ideas/solutions?

EDIT: Whoops... I just found out that my own "solution" didn't even work as I expected. A correct solution would now be _very_ much appreciated! :)

1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 21 Nov 2008, 09:55 AM

Hi Kenneth,

Generally, the page index should be reset when you change the page size of the grid. This can be verified on the following online demo of the grid:

http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/Programming/Slider/DefaultCS.aspx

(change the pager mode to 'Advanced' or 'NextPrevNumericAndAdvanced' havigatio to a different page and set page size greater than 100 for example)

Alternatively, if you change the page size manually, simply set the CurrentPageIndex of the grid to 0 and rebind the control invoking its Rebind() method to attain the same effect.

Best regards,

Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Bent
Top achievements
Rank 2
Answers by
Sebastian
Telerik team
Share this question
or