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

Custom RadListFilterPopup

2 Answers 39 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Argos
Top achievements
Rank 1
Argos asked on 05 Nov 2013, 10:13 AM
Hi,

I'd like to customize RadListFilterPopup. I need to display in it only "Available Filters" directly, meens without menu element (attachement 1), like filters in GridViewRowElement. I have to use  excel-like filtering instead of clasic GridViewRowElement becouse in some columns I need checkbox list filter which is given in excel-like filtering.

I write below snippet:


void radGridView1_FilterPopupRequired(object sender, Telerik.WinControls.UI.FilterPopupRequiredEventArgs e)
        {
            RadListFilterPopup popup = (RadListFilterPopup)e.FilterPopup;

            var radMenuItems = ((RadMenuItem)popup.Items[1]).Items;

            popup.Items.Clear();

            popup.Items.AddRange(radMenuItems);
        }


It works fine - displays only "Available Filters". But the problem is that after clicking on some element (e.g "Start with" ) the "blue dialog" appears under the filter list, or in another words, filter list isn't closed ( it is closed after click on "blue dialog" ).

So,

1) How can I close filter list, after clicking on one of it element

2) Is there a simpler way to assign only "Available filters" to filter icon (without rest standard content of RadListFilterPopup) - e.g. use another FilterPopup?

thanks in Advance.

2 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 08 Nov 2013, 09:15 AM
Hi Argos,

Thank you for contacting Telerik Support.

Indeed, in this case the cleanest solution would be to use a custom RadListFilterPopup, for example you can use the following class:
public class MyFilterPopup : RadListFilterPopup
{
    private RadListFilterPopup otherPopup;
 
    public MyFilterPopup(GridViewDataColumn dataColumn, RadListFilterPopup otherPopup)
        : base(dataColumn)
    {
        this.otherPopup = otherPopup;
    }
 
    protected override void OnPopupOpened()
    {
        base.OnPopupOpened();
 
        RadItemOwnerCollection radMenuItems = ((RadMenuItem)otherPopup.Items[1]).Items;
        this.Items.Clear();
        foreach (RadMenuItem item in radMenuItems)
        {
            item.MouseUp += OnFilterMenuItemMouseUp;
            this.Items.Add(item);
        }
    }
 
    protected virtual void OnFilterMenuItemMouseUp(object sender, MouseEventArgs e)
    {
        this.Hide();
    }
 
    protected override void Dispose(bool disposing)
    {
        base.Dispose(disposing);
        foreach (RadMenuItem item in this.Items)
        {
            item.MouseUp -= OnFilterMenuItemMouseUp;
        }
    }
}

We hook the MouseUp event on each Item in the collection and hide the popup manually. The popup can be used as follows:
this.grid.FilterPopupRequired += (s, e) =>
{
    RadListFilterPopup oldPopup = (RadListFilterPopup)e.FilterPopup;
    GridViewDataColumn currentColumn = (s as GridHeaderCellElement).ColumnInfo as GridViewDataColumn;
    RadListFilterPopup popup = new MyFilterPopup(currentColumn, oldPopup);
    e.FilterPopup = popup;
};

I hope this will help.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Argos
Top achievements
Rank 1
answered on 27 Nov 2013, 08:54 AM
Hi George,

Thank you for your reply. Now it works perfect.

Best regards
Tags
GridView
Asked by
Argos
Top achievements
Rank 1
Answers by
George
Telerik team
Argos
Top achievements
Rank 1
Share this question
or