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

Custom GridView Filter Popup

5 Answers 365 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hugo Furth
Top achievements
Rank 1
Hugo Furth asked on 27 May 2014, 03:17 AM
Hi All -

I looked thru the forum but could find an example of what I need to do. And that is

empty the filter popup and populate it with my own entries.

For simplicity I only need 3 fields. The underlying column will contain only "A", "B", or blank/null so I would like the popup 
to contain only those values. Even if the column could contain "C" or "D", I don't want to filter on that.

I know this can't be too difficult but I was unable to find an example and the code I wrote didn't work properly.

Any help appreciated.
Regards,
Hugo

5 Answers, 1 is accepted

Sort by
0
Hugo Furth
Top achievements
Rank 1
answered on 27 May 2014, 03:27 AM
Forgot.....also need an "All" selection.

Thx,
Hugo
0
Accepted
Dimitar
Telerik team
answered on 28 May 2014, 02:23 PM
Hi Hugo,

Thank you for writing.

The FilterPopupInitialized event can be used for both, to remove any items you want and to change the items in the treeview:
void radGridView1_FilterPopupInitialized(object sender, Telerik.WinControls.UI.FilterPopupInitializedEventArgs e)
{
    RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup;
    if (popup != null)
    {
        popup.MenuElement.Items.RemoveAt(0);
        popup.MenuElement.Items.RemoveAt(0);
         
        popup.MenuTreeElement.DistinctListValues.Add("<empty>", "");
        popup.MenuTreeElement.DistinctListValues.Remove("C");
        popup.MenuTreeElement.DistinctListValues.Remove("D");
    }
}

Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Hugo Furth
Top achievements
Rank 1
answered on 09 Jun 2014, 12:28 AM
Your answer greatly appreciated.

Hugo
0
Alec
Top achievements
Rank 1
answered on 23 Apr 2020, 06:18 PM

Hi Dimitar,

I know that this is an old issue, but I am trying the same thing now, and I have been able to use this technique to add values to the filter popup menu tree element distinct list, but when I try to filter on those elements, I get no value passed.  Do I need to do something to get the filter to work for these added list values?

Thanks,

Alec

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Apr 2020, 08:58 AM
Hello, Alec,

Following the provided code snippet, I have prepared a sample project to test the behavior on my end with the latest version. You can find below the default filter popup:

After handling the FilterPopupInitialized event, the below result is accomplished:

        public RadForm1()
        {
            InitializeComponent();

            this.radGridView1.Columns.Add("Name");
            this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

            this.radGridView1.Rows.Add("A");
            this.radGridView1.Rows.Add("B");
            this.radGridView1.Rows.Add("C");
            this.radGridView1.Rows.Add("D");

            this.radGridView1.EnableFiltering = true;
            this.radGridView1.ShowHeaderCellButtons = true;
            this.radGridView1.ShowFilteringRow = false;

            this.radGridView1.FilterPopupInitialized+=radGridView1_FilterPopupInitialized;
        }

        private void radGridView1_FilterPopupInitialized(object sender, FilterPopupInitializedEventArgs e)
        {
            RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup;
            if (popup != null)
            {
                popup.MenuElement.Items.RemoveAt(0);
                popup.MenuElement.Items.RemoveAt(0);

                popup.MenuTreeElement.DistinctListValues.Add("<empty>", "");
                popup.MenuTreeElement.DistinctListValues.Remove("C");
                popup.MenuTreeElement.DistinctListValues.Remove("D");
            }
        }

If you uncheck some of the nodes, the filtering seems to work as expected:

I have attached my sample project. Could you please specify the exact steps how to reproduce the problem? Thank you in advance for your cooperation.

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
GridView
Asked by
Hugo Furth
Top achievements
Rank 1
Answers by
Hugo Furth
Top achievements
Rank 1
Dimitar
Telerik team
Alec
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or