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

Pre-defining items for the column filter?

2 Answers 64 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 21 Mar 2017, 09:57 PM

Let's say I have a very large (millions of records) DB of cars but one of the column (colors) has only a couple of different choices (red, green, blue, black, white).

When I'm binding the DB to the GridView (using pagination because I can't load the whole table at once and data virtualization is performing poorly on this amount of data) and trying to filter by color every time I open the filter editor I'm sending a query to my DB asking for Top 1000 Distinct colors which is really slow.

Now my question is, can I have a predefined list of available colors to use for my Filter Editor? Just create a List<String> and feed it to the editor?

Thank you.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dilyan Traykov
Telerik team
answered on 24 Mar 2017, 08:59 AM
Hello Alex,

You can use RadGridView's DistinctValuesLoading event in order to filter the displayed distinct values. Here's an example:

private void RadGridView_DistinctValuesLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDistinctValuesLoadingEventArgs e)
{
    if (e.Column == this.RadGridView.Columns["Color"])
    {
        e.ItemsSource = TopColors;
    }
}

Please let me know if this works for you.

Regards,
Dilyan Traykov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Alex
Top achievements
Rank 1
answered on 28 Mar 2017, 09:23 PM
Thank you Dilyan, this was exactly what I was looking for.
Tags
GridView
Asked by
Alex
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Alex
Top achievements
Rank 1
Share this question
or