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

DataPager with Windows datagrid

2 Answers 138 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Niraja
Top achievements
Rank 1
Niraja asked on 04 Nov 2019, 07:12 AM

I have an existing WPF application which uses Microsoft.Windows.controls.Datagrid. I want to add the RadDataPager to do the pagination, how can I do it? 

Here's my sample code. It displays the data but it doesn't do the pagination. All data is displayed in a single page.

<dg:DataGrid Name="dgRegistryDetails" FontSize="14" DockPanel.Dock="Bottom" Foreground="#FF07315B"

                         ItemsSource="{Binding}"   CanUserSortColumns="true"
IsReadOnly="True"    AutoGenerateColumns="False" >

 

<telerik:RadDataPager VerticalAlignment="Bottom" DisplayMode="FirstLastPreviousNextNumeric" Source="{Binding Items, ElementName=dgRegistryDetails}"  IsTotalItemCountFixed="True" x:Name="RadPager" PageSize="10" />

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Petrov
Telerik team
answered on 05 Nov 2019, 12:23 PM

Hi Niraja,

When using RadDataPager with a collection that does not implement IPagedCollectionView you have to use the component as the middle man. RadDataPager's Source property is bound to the view model and the DataGrid, in this case, is bound to RadDataPager's PagedSource property. You can have a look at the last example in the Getting started article of RadDataPager.

Here is how your code should look like:

<dg:DataGrid Name="dgRegistryDetails" 
FontSize="14" 
DockPanel.Dock="Bottom" 
Foreground="#FF07315B" 
ItemsSource="{Binding PagedSource, ElementName=dataPager}"   
CanUserSortColumns="true"
IsReadOnly="True"
AutoGenerateColumns="False" > 

<telerik:RadDataPager 
VerticalAlignment="Bottom" 
DisplayMode="FirstLastPreviousNextNumeric" 
Source="{Binding}"  
IsTotalItemCountFixed="True" 
x:Name="RadPager" 
PageSize="10" />

I hope this helps you out. Should you have further questions, I would be glad to assist.

Regards,
Ivan Petrov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Niraja
Top achievements
Rank 1
answered on 08 Nov 2019, 01:01 AM
Thanks so much. That helped me a lot
Tags
DataPager
Asked by
Niraja
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Niraja
Top achievements
Rank 1
Share this question
or