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

GridView with DataPager not refreshing when source changes

1 Answer 238 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 25 Oct 2011, 07:22 PM
Hi, I have a GridView with grouped data and a datapager applied directly to the grid's items collection as in the code below:

<telerik:RadDataPager x:Name="ResultsPager" PageSize="7" DisplayMode="FirstLastPreviousNextNumeric" Source="{Binding Items, ElementName=DashboardInventoryDetailsGrid}" AutoEllipsisMode="Both" NumericButtonCount="10" IsTotalItemCountFixed="True" />
<telerik:RadGridView x:Name="DashboardInventoryDetailsGrid" ItemsSource="{Binding InventoryDetails, Mode=OneWay}" ...


There are certain rows within the grid that when clicked, I add a row to the InventoryDetails (ObservableCollection).
When there is no DataPager, the grid displays the newly added row as expected. As soon as I add the DataPager, the grid no longer refreshes the contents, you have to page next, then back in order to see the new row.

Is this a known behaviour, and is there a workaround? Perhaps a property to enable...

Thanks,
-Robert

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 26 Oct 2011, 08:49 AM
Hello Robert,

This behavior is expected. Let me try to explain how things work.

When there is paging, the GridView shows only the current page of the entire collection. When an item is being added, edited or removed paging need to be re-calculated since the contents of all pages may change based on the add/edit/remove of the item. So we need to tell the grid to refresh. You have found one of the ways.

Can you try calling RadGridView.Rebind after you perform the edit. This will of course return you to page zero. An alternative would be to "remember" the page number you are on, do the addition, call Rebind and then call RadDataPager.MoveToPage(index) if you want to return to the page you were on.

I hope this helps. Let me know if there are problems with this approach.

All the best,
Ross
the Telerik team

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

Gadi
Top achievements
Rank 1
commented on 11 Aug 2021, 08:14 AM | edited

I have a similar problem after I added RadDataPager within a RadGridView , all updates in GridView stop to update the collection, only new rows updating after changing the RadDataPager page Index several times.

     <telerik:RadGridView 
            Name="my_radgridView"
             ScrollViewer.VerticalScrollBarVisibility = "Disabled"
            CanUserDeleteRows="{Binding CurrentPermission.CanDelete}"
            ItemsSource ="{Binding PagedSource, ElementName=dataPager}" />

      <telerik:RadDataPager
                x:Name="dataPager"
                DisplayMode="PreviousNextNumeric" 
                NumericButtonCount="10"
                PageSize="5"
                Source="{Binding Designs}"/>
Dinko | Tech Support Engineer
Telerik team
commented on 16 Aug 2021, 07:29 AM

I have double check your scenario and the RadGridView and DataPager are updated. You can check the attached project. When you run it click on the buttons at the bottom. You can see that the RadGridView and the RadDataPager are updated. May I ask you to check the project and let me know what I am missing from your scenario?
Tags
GridView
Asked by
Robert
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or