Custom RadListFilterPopup

3 posts, 0 answers
  1. Argos
    Argos avatar
    6 posts
    Member since:
    Aug 2012

    Posted 05 Nov 2013 Link to this post

    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. George
    Admin
    George avatar
    500 posts

    Posted 08 Nov 2013 Link to this post

    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 >>
  3. Argos
    Argos avatar
    6 posts
    Member since:
    Aug 2012

    Posted 27 Nov 2013 Link to this post

    Hi George,

    Thank you for your reply. Now it works perfect.

    Best regards
Back to Top