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

Deleting items from GridView when using a DataPager causes items to temporarily disappear

1 Answer 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason Nguyen
Top achievements
Rank 1
Jason Nguyen asked on 14 Jul 2010, 03:36 PM
I am using a RadDataPager with a RadGridView and am allowing the user to delete entries in the RadGridView.

Let's say I have two pages, and the PageSize is set to 10.  And let the first item on the second page be item x.
Now say the user is on the first page and deletes an item.  The first page then goes down to 9 items and does not list item x.  Then if the user goes to the second page, item x isn't listed there either.  But as soon as one goes back to the first page, then item x is listed on the first page.

Should item x have been automatically moved to the first page as soon as the deletion occurred?  If not, shouldn't item x still be listed on the next page?

Thanks in Advance,
Jason Nguyen

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 19 Jul 2010, 10:07 AM
Hello Jason Nguyen,

We have logged this issue. We will try to resolve it as soon as possible. You can follow the PITS Issue by its ID: 2710

We have updated your Telerik points for helping us identify this issue.

Until we fix the issue, there is a very simple workaround. Simply wrap your original collection into a System.Windows.Data.PagedCollectionView. Then bind both the grid and the pager to this IPagedCollectionView. This will make everything work correctly.

<UserControl x:Class="RadGridView_SL4_AR_1.MainPage"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:my="clr-namespace:RadGridView_SL4_AR_1"
             mc:Ignorable="d" d:DesignHeight="700" d:DesignWidth="700">
    <UserControl.Resources>
        <my:MyViewModel x:Key="MyViewModel"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot"
          Background="White"
          DataContext="{StaticResource MyViewModel}">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <telerik:RadGridView Grid.Row="0"
                             Name="clubsGrid"
                             ItemsSource="{Binding PagedClubs}"
                             AutoGenerateColumns="False"
                             Margin="5">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Established}"
                                            Header="Est."
                                            DataFormatString="{}{0:yyyy}"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding StadiumCapacity}"
                                            Header="Stadium"
                                            DataFormatString="{}{0:N0}"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
        <StackPanel Grid.Row="1" Orientation="Horizontal">
            <telerik:RadDataPager Name="radDataPager"
                                  Source="{Binding PagedClubs}"
                                  PageSize="2"/>
        </StackPanel>
    </Grid>
</UserControl>

public IPagedCollectionView PagedClubs
{
    get
    {
        if (this.pagedClubs == null)
        {
            this.pagedClubs = new PagedCollectionView(this.Clubs);
        }
 
        return this.pagedClubs;
    }
}

I have attached a sample project that does this.

Kind regards,
Ross
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Jason Nguyen
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or