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

Pager apparently resets if Grid ItemsSource updated

3 Answers 52 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 22 Sep 2011, 09:02 PM
I'm pretty sure I am doing something wrong here but can't figure it out.

My situation ;

I have a RadGridView bound to a PagedCollectionView (DataList).
<telerik:RadGridView x:Name="myGrid"  
          ItemsSource="{Binding DataList}"
          ColumnWidth="Auto" VerticalAlignment="Stretch"
          AutoGenerateColumns="False" HorizontalAlignment="Stretch"
          CanUserFreezeColumns="False"
          RowStyleSelector="{StaticResource selector}" >

 I also have a datapager that is connected to the grid via its Items property.
<telerik:RadDataPager Grid.Row="1"
    x:Name="radDataPager"
    PageSize="15"
    Source="{Binding Path=Items, ElementName=myGrid}"
    DisplayMode="All"
    AutoEllipsisMode="Both"
    NumericButtonCount="10"
    IsTotalItemCountFixed="True"/>

On initial load of the page, everything is fine.  I have 37 rows of data, I have 3 pages appearing in the pager. 

Now, the nature of the data is such that it has some computed fields that are generated by a stored procedure after certain updates.  So, after a save operation is performed, I make a call to the DomainService using a LoadBehaviour of RefreshCurrent basically to refresh the cached entity set on the client (as outlined here).  The problem I am having is when that refresh completes, I recreate the PagedCollectionView in my view model which causes the grid to update it's itemssource via its binding.  The page however seems to disconnect or reset.  Basically I end up after the save and refresh with one page and all 37 records displayed in the grid.  Paging appears to be turned off.

I hope this is clear and someone knows what I am doing wrong. 

Thanks.
Alex.

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 23 Sep 2011, 09:20 AM
Hello Alex,

I am not sure whether this would work, but can you try the following approach. Don't bind the pager to RadGridView.Items, but bind it directly to the PagedCollectionView property of your view model. You will have both RadGridView and RadDataPager bound to the PagedCollectionView.

Another experiment that you might easily try -- replace RadDataPager with the stock Microsoft DataPager. Is it behaving the same way or differently? This can help us identify the culprit.

Best wishes,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Alex
Top achievements
Rank 1
answered on 23 Sep 2011, 01:40 PM
Thanks for the suggestions Ross.

If I bind the RadDataPager directly to PagedCollectionView, then it seems to work.  This seems such an obvious thing to try, it did not occur to me.  This led me to try binding to the ItemsSource of the RadGrid instead of the Items property.  Again this appears to work as well.  Could it be that binding to the Items property is the culprit?  If so, examples are misleading as they instruct devs to bind to this property with the RadPager.

In any event, thanks again for the pointers, they certainly helped me find what I was missing and reslove my issue.

Alex.

0
Rossen Hristov
Telerik team
answered on 23 Sep 2011, 01:46 PM
Hello Alex,

This is when there are only pager and grid. Then the pager binds to the Items of the grid, since they are in fact an IPagedCollectionView (the grid internally creates something similar to the stock PagedCollectionView).

But when you have an external PagedCollectionView like in your case, you should bind directly to it.

Something like this in ASCII art:

RadGridView  ----> PagedCollectionView <----- RadDataPager

All the best,

Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
DataPager
Asked by
Alex
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Alex
Top achievements
Rank 1
Share this question
or