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

Pagination needs QueryableDomainServiceCollectionView. How to obtain it?

3 Answers 29 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vitor
Top achievements
Rank 1
Vitor asked on 08 Mar 2016, 09:44 AM

Dear Telerik Support
I just started using your controls for WPF, to see if it suits the needs of our company
Starting by doing basic examples, I stumbled upon the RadGridView pagination
I am trying to use this example
http://demos.telerik.com/silverlight/#DomainDataSource/MVVM and
and this documentation
http://docs.telerik.com/devtools/wpf/controls/raddatapager/getting-started#adding-raddatapager
But it seems my grid wont page if I dont use this

   this.view = new QueryableDomainServiceCollectionView<Customer>(context, getCustomersQuery);
   
   this.view.PageSize = 10;

thus attributing the PageSize to it.
right now I use a ObservableCollection<Entity> List.

So my question is: Where how can I use the above mentioned class (QueryableDomainServiceCollectionView) to support my need of pagination?
I don't want to paginate it manually, by using the Unbound mode. and I would prefer to avoid that all data goes into memory

I wish I could attach a zip file of my project. but since I cannot, here is the code (note: you must install the PropertyChanged.Fody nugget in order to run it):

XAML

<Window x:Class="TelerikWpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local="clr-namespace:TelerikWpfApp1"
Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
<Grid Name="grid">
<Grid.DataContext>
<local:ViewModel/>
</Grid.DataContext>
<telerik:RadGridView x:Name="radGridView"
HorizontalAlignment="Left"
Margin="23,30,0,0" VerticalAlignment="Top"
Height="234" Width="468"
ItemsSource="{Binding List}" AutoGenerateColumns="True">
<telerik:RadGridView.Columns>
<telerik:GridViewColumn BindingGroup="{Binding id}"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<telerik:RadDataPager x:Name="radDataPager"
Margin="23,264,26,27"
PageSize="5"
DisplayMode="PreviousNext"
Source="{Binding List, ElementName=radGridView}" />
</Grid>
</Window>

XAML.CS

 
using System.Windows;
namespace TelerikWpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
ViewModel vm = null;
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
vm = grid.DataContext as ViewModel;
vm.Load();
}
}

 

VIEWMODEL.cs

using PropertyChanged;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace TelerikWpfApp1
{
[ImplementPropertyChanged]
public class ViewModel
{
public ObservableCollection<Entity> List { get; set; }
public void Load()
{
List = GetList().ToObservableCollection();
}
List<Entity> GetList()
{
List<Entity> list = new List<Entity>();
for (int i = 0; i < 100; i++)
{
list.Add(new Entity() { comment = "dasd", id = 1, name = "fefe" });
list.Add(new Entity() { comment = "xxcv", id = 2, name = "dewd" });
list.Add(new Entity() { comment = "zzz", id = 3, name = "jjj" });
}
return list;
}

//public void Save(Entity item, string comment)
//{
// if (item.comment != comment)
// {
// //controller.Save(); }
// }
//}
}
public class Entity
{
public int id { get; set; }
public string name { get; set; }
public string comment { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
public static class ListExtensions
{
public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> items)
{
var c = new ObservableCollection<T>();
foreach (var item in items)
{
c.Add(item);
}
return c;
}
}
}

 

Thank you!!!!

3 Answers, 1 is accepted

Sort by
0
Vitor
Top achievements
Rank 1
answered on 09 Mar 2016, 08:02 AM

looking forward to hear from you!

guess pagination is pretty basic

0
Stefan
Telerik team
answered on 10 Mar 2016, 03:11 PM
Hi Vitor,

Generally, QueryableDomainServiceCollectionView is part of the UI for Silverlight suite, but you mentioned using the UI for WPF one. Can you please clarify this?

Best Regards,
Stefan X1
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Vitor
Top achievements
Rank 1
answered on 11 Mar 2016, 11:03 AM
Hello Stefan,
Yes, what you said proceeds. I was using the wrong documentation.
But nonetheless I still have issues with the pagination.

please refer to this ticket. I messed up this one.

http://www.telerik.com/forums/gridview---all-basic-functionalities-in-one-sample

Tags
GridView
Asked by
Vitor
Top achievements
Rank 1
Answers by
Vitor
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or