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

Paging of grouped data

8 Answers 279 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 30 Mar 2012, 05:08 PM
Hi I am using RadDataPager with RadDataView to show only 5 records at the time in the grid
But when I am using Grouping on the datagrid the Pager returns 5 Group headers per page and the actual records are much more...

Is there a way to fix it?

<telerik:RadDataPager
    Grid.Row="3"
    x:Name="radDataPager"
        Source="{Binding SearchResults}"
        PageSize="5" 
        DisplayMode="All"
        IsTotalItemCountFixed="True"
    />
 
 
<telerik:RadGridView
        x:Name="grdSearchResults"
        Grid.Row="4"
        ItemsSource="{Binding PagedSource, ElementName=radDataPager}"
        IsBusy="{Binding IsSearchActive}"
        IsReadOnly="True"
        CanUserDeleteRows="False"
        CanUserInsertRows="False"
        ShowGroupPanel="False"
        Width="auto"
        AutoGenerateColumns="False"
        ReorderColumnsMode="Interactive"
        RowIndicatorVisibility="Collapsed"
        AutoExpandGroups="True"
        SelectionMode="Extended">
    <telerik:RadGridView.GroupDescriptors>
        <telerik:GroupDescriptor Member="AccountNumber" SortDirection="Ascending" />
        <telerik:GroupDescriptor Member="DocumentType" SortDirection="Ascending" />
    </telerik:RadGridView.GroupDescriptors>
    <i:Interaction.Behaviors>
        <Behaviors:MultiSelectBehavior SelectedItems="{Binding SelectedDocuments}"/>
    </i:Interaction.Behaviors>
 
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn
                Header="ID"
                DataMemberBinding="{Binding EntryId}"
                 />
        <telerik:GridViewDataColumn
                Header="Status"
                DataMemberBinding="{Binding Status}"
                />
        <telerik:GridViewDataColumn
                Header="Created"
                DataMemberBinding="{Binding CreateDate}"
                />
 
        <telerik:GridViewSelectColumn />
 
    </telerik:RadGridView.Columns>
 
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="RowActivated" >
            <i:InvokeCommandAction Command="{Binding DisplayViewCommand}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
 
</telerik:RadGridView>

8 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 02 Apr 2012, 07:45 AM
Hi,

 Please refer to this forum thread where the paging for a grouped RadGridView is discussed.

Greetings,
Didie
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Michael
Top achievements
Rank 1
answered on 09 Apr 2012, 03:08 PM
Hi Didie,

I do not follow how the forum thread you reffered applies to my case.

I am not using code behind and my RadDataPager is bound to ObservableCollection in my ViewModel.

Can you please clarify what should I do in order to fix the problem? 
0
Vlad
Telerik team
answered on 09 Apr 2012, 03:11 PM
Hi,

 Here is the exact reply in this thread for more info.

Greetings,
Vlad
the Telerik team

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

0
Michael
Top achievements
Rank 1
answered on 09 Apr 2012, 03:30 PM
Vlad,

Thank you for the fast reply. I am still confused as for where the PagedCollectionView should apply in my code?
Can you please give me detailed instructions on how to modify MY code?

Thanks
0
Vlad
Telerik team
answered on 09 Apr 2012, 03:34 PM
Hello,

 What we are trying to say is that the grid (and the collection behind the grid) will page groups by default - not group items. If your scenario is different you should implement your own paging logic using IPagedCollectionView.

Kind regards,
Vlad
the Telerik team

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

0
Michael
Top achievements
Rank 1
answered on 09 Apr 2012, 03:46 PM
>> What we are trying to say is that the grid (and the collection behind the grid) will page groups by default - not group items

So there is no way to change default behaviour? Then it is not default but very limited behaviour.

Of course I can implement my paging on my own just by using LINQ's abilities to page data using  Skip() and Take() functions.
But that will prevent me from using out of the box RadDataPager control as I have for all other grids.

Why not to add a property to the RadDataPager that will control how the paging should work: by groups or by records?

As for IPagedCollectionView, can you provide a sample of how that should be implemented? (link to a documentation on the interface would be great!) 

Thanks
0
Vlad
Telerik team
answered on 10 Apr 2012, 06:54 AM
Hello,

We cannot add such property/behavior for RadDataPager since grouping is done very differently across various collections (standard CollectionView, our QueryableCollectionView, WCF RIA Services in Silverlight, etc.) while the pager is universal paging component and does not care/know anything about grouping. 

I believe that you will find a lot of IPagedCollectionView implementations in the web including MSDN - our interface is exact copy of the original Silverlight interface.

All the best,
Vlad
the Telerik team

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

0
Rossen Hristov
Telerik team
answered on 10 Apr 2012, 08:51 AM
Hi,

A quick follow-up. Here are two alternatives.

A. RadDataPager has the so called Unbound Mode.
 
Since you mentioned that you can Skip and Take on your flat collection, if you use the Unbound Mode you can Skip and Take on the respective event.

B. RadDataPager has a property called PagedSource. If you pass in the original collection to RadDataPager.Source, you will get the current page of data our from its PagedSource property. You can cast the PagedSource to INotifyCollectionChanged and respond to collection changes and fill another ObservableCollection with the data. Or you can wrap this PagedSource in another collection and internally respond to CollectionChaged's. The idea is to feed this other collection to RadGridView.ItemsSource so that paging happens before grouping.

The idea is to do the paging before the grouping so that RadGridView will never know that someone is paging its data. It will simply think that its ItemsSource is a collection with several items (i.e. PageSize) and will group these items.

source collection -> RadDataPager -> only one page of data -> RadGridView -> grouping will be done over this one page of data and the grid will never know what happened before it.

I hope this helps.

Regards,
Ross
the Telerik team

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

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