WinForms Radgriview filter boolean

4 posts, 1 answers
  1. Armen
    Armen avatar
    5 posts
    Member since:
    Jul 2011

    Posted 03 Apr 2012 Link to this post

    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" ?  Maybe it is possible to do in FilterPopupRequired Event ?
  2. Answer
    Nikolay
    Admin
    Nikolay avatar
    1805 posts

    Posted 03 Apr 2012 Link to this post

    Hello Armen,

    Thank you for writing.

    The context specific strings that you get in the treeview are determined by the CurrentCulture. There is no direct way to modify these strings. Still, you can easily achieve the desired requirement by handling three events: FilterPopupRequired, PopupClosed, NodeAdded. I am attaching a sample project that demonstrates the full approach.

    I hope this helps.

    Kind regards,
    Nikolay
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. Armen
    Armen avatar
    5 posts
    Member since:
    Jul 2011

    Posted 04 Apr 2012 Link to this post

    Nikolay, thank you. That sample project helped me. Version of my
        Telerik components  differ from yours, MenuTreeElement is
        non-public property in it, so I had to make some tricks.
        Final result look like this: 

               private
    void gvMain_FilterPopupRequired(object sender, Telerik.WinControls.UI.FilterPopupRequiredEventArgs e)
            {
                if (e.Column.Name == "IsMarked")
                {
                    RadListFilterPopup popup = new RadListFilterPopup(e.Column);
     
                    RadTreeView tree = (RadTreeView)popup.Controls[1];
                    tree.NodeAdded += new RadTreeView.RadTreeViewEventHandler(tree_NodeAdded);
                    popup.PopupClosed += new RadPopupClosedEventHandler(popup_PopupClosed);
     
                    e.FilterPopup = popup;
                }
            }
     
            void popup_PopupClosed(object sender, RadPopupClosedEventArgs args)
            {
                RadListFilterPopup popup = sender as RadListFilterPopup;
     
                RadTreeView tree = (RadTreeView)popup.Controls[1];
                tree.NodeAdded -= new RadTreeView.RadTreeViewEventHandler(tree_NodeAdded);
            }
     
            void tree_NodeAdded(object sender, RadTreeViewEventArgs e)
            {
                if (e.Node.Text.ToLower() == "true")
                {
                    e.Node.Text = BaseHelper.Instance.IsMarkeredTextTrue;
                }
                else if (e.Node.Text.ToLower() == "false")
                {
                    e.Node.Text = BaseHelper.Instance.IsMarkeredTextFalse;
                }
            }
  4. Nikolay
    Admin
    Nikolay avatar
    1805 posts

    Posted 05 Apr 2012 Link to this post

    Hello Armen,

    I am glad to hear that you managed to incorporate my solution with the Telerik version that you are using. Still, I would recommend updating to the latest release of our suite as it contains many improvements and innovations.

    All the best,
    Nikolay
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top