GridView with DataPager not refreshing when source changes

2 posts, 0 answers
  1. Robert
    Robert avatar
    12 posts
    Member since:
    Jun 2011

    Posted 25 Oct 2011 Link to this post

    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
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 26 Oct 2011 Link to this post

    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 >>

Back to Top