Paging of grouped data

9 posts, 0 answers
  1. Michael
    Michael avatar
    23 posts
    Member since:
    Jun 2012

    Posted 30 Mar 2012 Link to this post

    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>
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 02 Apr 2012 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Michael
    Michael avatar
    23 posts
    Member since:
    Jun 2012

    Posted 09 Apr 2012 Link to this post

    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? 
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Apr 2012 Link to this post

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

  6. Michael
    Michael avatar
    23 posts
    Member since:
    Jun 2012

    Posted 09 Apr 2012 Link to this post

    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
  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 09 Apr 2012 Link to this post

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

  8. Michael
    Michael avatar
    23 posts
    Member since:
    Jun 2012

    Posted 09 Apr 2012 Link to this post

    >> 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
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 10 Apr 2012 Link to this post

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

  10. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 10 Apr 2012 Link to this post

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

Back to Top
UI for WPF is Visual Studio 2017 Ready