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

Filtering across Datagrid Pages

4 Answers 96 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gokul Nagarajan
Top achievements
Rank 1
Gokul Nagarajan asked on 21 Dec 2009, 01:16 PM
Hi,
We have a telerik datagrid that displays 10 record per page. We are using data pager to implement paging. In the datapager we initially assign 400 records, and display 10 records on click of the next and previous buttons.
Now, when the filter icon is clicked we see that the values appearing the options for filter are, values that are present in the page that is currently displayed. We want to have all the values that are assigned to the data pager(from the 400 record set).
Do we have a solution for this. Please update.

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 22 Dec 2009, 11:12 AM
Hi Gokul Nagarajan,

There is an event called DistinctValuesLoading. You can attach to it and pass in anything to be shown as distinct values. So I guess that you can pull all of the data from the server in some way and feed it as distinct values.

By the way we are currently in the process of implementing a functionality that will let you do anything on the server, including distinct value population. Also, we will try to make the distinct value population to be asynchronous. I hope that this functionality will be soon ready and we will publish it.

Greetings,
Ross
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
Gokul Nagarajan
Top achievements
Rank 1
answered on 22 Dec 2009, 01:12 PM
Hi Ross,
From your response I understand that I can load values(DistinctValueLoading) that are not displayed in the current page. In such cases, can I perform a filtering on the records that are available on the server side along with the ones available in the client side? Can you please share any code snippets in this regard?

Hope my question is clear to you? Please respond to me if you need more clarity.

Regards,
Gokul.
0
Rossen Hristov
Telerik team
answered on 22 Dec 2009, 01:47 PM
Hello Gokul Nagarajan,

By setting e.ItemsSource you can pass in *any* values that you like. So you can obtain all the distinct values from the server and pass them as ItemsSource, but the implementation is up to you. The only problem is that currently they will not be populated asynchronously (we do not detect whether you have passed in an INotifyCollection changed as ItemsSource) and the UI thread might block, but we are in the process of resolving this and once we are ready we will publish an example of how to get distinct values from the server in an asynchronous manner.

Once distinct values are obtained, you can attach to the Filtering event and filter on the server like we have demonstrated in this online example. Here is part of the source code from the online example:

using System;
using System.Linq;
 
namespace Telerik.Windows.Examples.GridView.DomainDataSource
{
    /// <summary>
    /// Interaction logic for Example.xaml
    /// </summary>
    public partial class Example
    {
        public Example()
        {
            InitializeComponent();
        }
 
        private void AddDomainDataSourceFilterDescriptor(Telerik.Windows.Data.FilterDescriptor descriptor)
        {
            System.Windows.Data.FilterDescriptor fd = new System.Windows.Data.FilterDescriptor();
            fd.PropertyPath = descriptor.Member;
            fd.Value = new System.Windows.Data.Parameter();
            fd.Value.Value = descriptor.Value;
            fd.Operator = CreateRiaFilterOperator(descriptor.Operator);
            DomainDataSource1.FilterDescriptors.Add(fd);
        }
 
        private void RemoveDomainDataSourceFilterDescriptor(Telerik.Windows.Data.FilterDescriptor descriptor)
        {
            System.Windows.Data.FilterDescriptor fd =
                (from d in DomainDataSource1.FilterDescriptors
                 where d.PropertyPath == descriptor.Member &&
                       d.Operator == CreateRiaFilterOperator(descriptor.Operator) &&
                       d.Value.Value == descriptor.Value
                 select d).FirstOrDefault();
 
            if (fd != null)
            {
                DomainDataSource1.FilterDescriptors.Remove(fd);
            }
        }
 
        private void RadGridView1_Filtering(object sender, Telerik.Windows.Controls.GridView.GridViewFilteringEventArgs e)
        {
            using (DomainDataSource1.DeferLoad())
            {
                foreach (Telerik.Windows.Data.FilterDescriptor d in e.Removed)
                {
                    RemoveDomainDataSourceFilterDescriptor(d);
                }
 
                foreach (Telerik.Windows.Data.FilterDescriptor d in e.Added)
                {
                    AddDomainDataSourceFilterDescriptor(d);
                }
            }
        }
 
        private static System.Windows.Data.FilterOperator CreateRiaFilterOperator(Telerik.Windows.Data.FilterOperator filterOperator)
        {
            return (System.Windows.Data.FilterOperator) Enum.Parse(typeof(System.Windows.Data.FilterOperator), filterOperator.ToString(), true);
        }
    }
}

The above code filters all data records on the server.

Make sure you check out our blogs and our release notes for each internal build. Once we are ready with the example I mentioned -- you will hear about it. I hope this helps.

Sincerely yours,
Ross
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
Gani
Top achievements
Rank 1
answered on 20 Mar 2013, 03:32 PM
Hi,
I have the same problem as yours, like i have 10 pages but when i apply filter it filters only based on the current page, can you help on this how to overcome this issue. its very urgent to me ..am using telerik RadGridView silverlight.
Tags
GridView
Asked by
Gokul Nagarajan
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Gokul Nagarajan
Top achievements
Rank 1
Gani
Top achievements
Rank 1
Share this question
or