telerikbooleanfilteringradgridview

Telerik WinForms Radgriview filter boolean


I am using Telerik WinForms RadGridView Control, I have set up Excel-like filtering, everything in fine, but I have a little problem. When I am filtering a Boolean field, in filter popup their are values: "True" and "False". Is it possible to change them on something more user-friendly, like "Yes" and "No" ?


Solution

  • People from Telerik helped me to solve this problem :)

    http://www.telerik.com/community/forums/winforms/gridview/winforms-radgriview-filter-boolean.aspx

    To avoid a link only answer which isn't ideal in case the link goes down. Here is the relevant code to solve the problem:

    void radGridView1_FilterPopupRequired(object sender, FilterPopupRequiredEventArgs e)
    {
        RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup;
        if (popup != null)
        {
            RadTreeView tree = popup.MenuTreeElement.TreeView;
            tree.NodeAdded += new RadTreeView.RadTreeViewEventHandler(tree_NodeAdded);
            popup.PopupClosed += new RadPopupClosedEventHandler(popup_PopupClosed);
        }
    }
    
    void popup_PopupClosed(object sender, RadPopupClosedEventArgs args)
    {
        RadListFilterPopup popup = sender as RadListFilterPopup;
        popup.MenuTreeElement.TreeView.NodeAdded -= new RadTreeView.RadTreeViewEventHandler(tree_NodeAdded);
    }
    
    void tree_NodeAdded(object sender, RadTreeViewEventArgs e)
    {
        if (e.Node.Text == "False")
        {
            e.Node.Text = "No";
        }
        else if (e.Node.Text == "True")
        {
            e.Node.Text = "Yes";
        }
    }