Hi,
How do I set the CurrentPageIndex after data has been data bound to the grid?My scenario is as follows;A user is on page 3, makes some modifications and hits save. We're doing a some processing,and need to reload the entire sheet.How do I automatically jump back to page 3 after the updated data is rebound to the grid? Setting the CurrentPageIndex throws an exception.Is there some kind of event I can subscribe to?
Thanks!
So, are you setting the ItemSource to the collection immediately? Or are you reloading the UserControl in which the XamWebGrid is on?
If you're just changing the ItemSource, then you should be able to set the CurrentPageIndex immediately.
Otherwise, if you're reloading the XamWebGrid Control, you can set the currentPageIndex in the loaded event of the XamWebGrid.
-SteveZ
Thanks for your reply.
I'm setting the ItemSource "directly" using data binding, and when I try to set the CurrentPageIndex, I get the following exception;
The page index 2 is invalid. The value must be between 1 and the total PageCount.
I know for a fact that there are at least 3 pages. My collection contains 56 items, and I have set the PageSize to 20.
So I got this thing working by trying and failing a bit... What I did was the following;1) Before reloading my data from the server, I reset the CurrentPageIndex to 12) Got my data from the server, and set my Items property to the new collection so the grid could data bind to the new data. (The ItemSource of the grid is data bound to my Items property, which is an ObservableCollection<T>)3) Called UpdateLayout() on the grid4) Set the CurrentPageIndex to whatever value it was prior to reloading the data.If I did not reset the CurrentPageIndex to 1 prior to reloading the data, setting the CurrentPageIndex did not have any effect...it was alwasy 1 not matter what I tried to set it to.If I did not call UpdateLayout() before setting the CurrentPageIndex, I got the exception mentioned in my previous post.
That is a bug.
Thanks to your steps, i was able to reproduce this issue, and fix it.
The issue should be addressed in the next Service Release.
Thanks