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

Customize filtering checkbox list

2 Answers 67 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 30 Jan 2013, 11:09 PM
My client wants to customize the column filters checkbox list that shows all the distinct values of the result set for that column.

For example, right now the items on the column filters check box list are:
[null]
0
1
2

Is it possible to remove the [null] option from only the checkbox list of the column filter but still have that [null] be part of the result set of the actual radGridView (albeit not filterable)? So that the column filters checkbox list would instead look like:
0
1
2

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 31 Jan 2013, 10:27 AM
Hi,

You could subscribe for the DistinctValuesLoading event of the RadGridView and load just the values you would like to. This help article may be helpful as an example.

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Shawn
Top achievements
Rank 1
answered on 31 Jan 2013, 09:44 PM
Thanks Didie, that worked great!

Took me a bit to realize I needed to cast the values to the data type stored in the column. Here's the code I ended up using for DistinctValuesLoading event:
void CodeBehindHook_DistinctValuesLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDistinctValuesLoadingEventArgs e)
{
    var filterItems = ((Telerik.Windows.Controls.RadGridView)sender).GetDistinctValues(e.Column, false);
    e.ItemsSource = filterItems.Cast<decimal?>().Where(itm => itm.HasValue);
}
Tags
GridView
Asked by
Shawn
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Shawn
Top achievements
Rank 1
Share this question
or