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

[Solved] Using the DataPager with Observable Collections

9 Answers 261 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Scott
Top achievements
Rank 1
Scott asked on 27 Aug 2009, 08:11 PM
Folks,

I see lots of example on using the DataPager with a DomainDataSource, but need to set these programatically against an Observable Collection derived from a custom class.

I am using Q2 2009 and Blend 3.

Please advise.

9 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 31 Aug 2009, 12:14 PM
Hi Scott,

I'm not sure about ObservableCollection<> (you may need to implement IPagedCollectionView) however you can use directly PagedCollectionView instead. Here is an example:

XAML
<UserControl x:Class="SilverlightApplication2.Page" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"  
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    <Grid x:Name="LayoutRoot" Background="White"
        <Grid.RowDefinitions> 
            <RowDefinition /> 
            <RowDefinition Height="30" /> 
        </Grid.RowDefinitions> 
        <telerik:RadGridView x:Name="RadGridView1" /> 
        <data:DataPager x:Name="DataPager1" PageSize="10" Grid.Row="1" /> 
    </Grid> 
</UserControl> 
 


C#
namespace SilverlightApplication2 
    public partial class Page : UserControl 
    { 
        public Page() 
        { 
            InitializeComponent(); 
 
            var data = new PagedCollectionView(from i in Enumerable.Range(0, 100) 
                                       select new MyObject() 
                                       { 
                                           ID = i, 
                                           Name = String.Format("Name{0}", i) 
                                       }, false ,false); 
 
 
            RadGridView1.ItemsSource = DataPager1.Source = data; 
        } 
    } 
 
    public class MyObject 
    { 
        public int ID { getset; } 
        public string Name { getset; } 
    } 
 



Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Scott
Top achievements
Rank 1
answered on 01 Sep 2009, 04:01 PM
NOTE: For folks wanting to use the PagedCollectionView you need a reference to System.Windows.Data typically found in the Silverlight SDK Libraries folder.

Thanks Vlad.
0
Tushar
Top achievements
Rank 1
answered on 05 Sep 2009, 08:47 PM
Hi,

Binding PagedCollectionView to the RadGridView limits the filter to the current PageSize of the DataPager. So if you set PageSize to 5, filter displays only 5 records and not all the values for that column in the Collection.

How do i achieve serverside filtering of records on the entire collection and not just the PageSize on the datapager.

Thanks,
Tushar
0
Vlad
Telerik team
answered on 07 Sep 2009, 05:23 AM
Hello Tushar,

Such demo can be found here:
http://demos.telerik.com/silverlight/#GridView/DomainDataSource

Regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Justin Brown
Top achievements
Rank 1
answered on 22 Sep 2009, 07:17 AM
Hi,

Are there any plans to enable client-side filtering when using the DataPager with the RadGridView? This is a highly desirable feature for my organisation.

If not, can you offer any guidance on how it may be easily implemented? It seems that it may be quite easy to capture the filter event and then filter the paged collection.

Kind regards,
Justin
0
Vlad
Telerik team
answered on 23 Sep 2009, 06:33 AM
Hi Justin,

Generally the grid will filter by default completely on the client however only current page items. On posted demo you can find how to filter server-side.

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dharmin Parekh
Top achievements
Rank 2
answered on 14 Jan 2010, 02:00 AM
What if custom filtering needs to be implemented on the server without using the domain data source control. Just like a PagedCollectionView object.

I have implemented some filtering on the server, but it is not extensive enough to support all the filtering options provided by the grid filter and i don't want to end up creating my own extensive filtering class.

Is there a sample that I can refer to, or am I missing something.

Thank you
Dharmin
0
Dharmin Parekh
Top achievements
Rank 2
answered on 14 Jan 2010, 02:01 AM
Hi,


What if custom filtering needs to be implemented on the server without using the domain data source control. Just like a PagedCollectionView object.

I have implemented some filtering on the server, but it is not extensive enough to support all the filtering options provided by the grid filter and i don't want to end up creating my own extensive filtering class.

Is there a sample that I can refer to, or am I missing something.

Thank you
Dharmin
0
Vlad
Telerik team
answered on 14 Jan 2010, 07:20 AM
Hello,

Finally you will implement something like WCF Ria services :). It will be better if you use them if you want advanced filtering.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Scott
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Scott
Top achievements
Rank 1
Tushar
Top achievements
Rank 1
Justin Brown
Top achievements
Rank 1
Dharmin Parekh
Top achievements
Rank 2
Share this question
or