Customize filtering checkbox list

3 posts, 1 answers
  1. Shawn
    Shawn avatar
    10 posts
    Member since:
    Mar 2011

    Posted 30 Jan 2013 Link to this post

    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. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 31 Jan 2013 Link to this post

    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.

  3. Shawn
    Shawn avatar
    10 posts
    Member since:
    Mar 2011

    Posted 31 Jan 2013 Link to this post

    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);
    }
Back to Top