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

WinForms Radgriview filter boolean

3 Answers 173 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Armen
Top achievements
Rank 1
Armen asked on 03 Apr 2012, 08:46 AM
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 ?

3 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 03 Apr 2012, 04:41 PM
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 >>
0
Armen
Top achievements
Rank 1
answered on 04 Apr 2012, 09:00 AM
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;
            }
        }
0
Nikolay
Telerik team
answered on 05 Apr 2012, 10:58 AM
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 >>
Tags
GridView
Asked by
Armen
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Armen
Top achievements
Rank 1
Share this question
or