Filtering gridview winfroms - how to select all

3 posts, 0 answers
  1. Peter
    Peter avatar
    2 posts
    Member since:
    Jun 2013

    Posted 03 Jun 2013 Link to this post

    I am using a radgridview for winforms and I am enable the filtering. I am not able to find how capture the select all inside the filter.
    The event FilterChanging triggered only when the filter is changed if nothing is changed then the event does nothing.

    Is it possible to add my custom message on the bottom on the filter like the picture bellow - selectionall.png?

    In other word I want to be able to capture when we select the all filters or do a custom message on the bottom.

    Thanks
  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    717 posts

    Posted 06 Jun 2013 Link to this post

    Hi Peter,

    Thank you for writing.

    You can subscribe to the NodeCheckedChanging of the tree view found inside the filter popup. Here is how to do that:
    this.radGridView1.FilterPopupInitialized += radGridView1_FilterPopupInitialized;
     
    private bool isFirstShow = false;
     
    private void radGridView1_FilterPopupInitialized(object sender, FilterPopupInitializedEventArgs e)
    {
        RadListFilterPopup listFilterPopup = e.FilterPopup as RadListFilterPopup;
     
        if (listFilterPopup == null)
        {
            return;
        }
     
        isFirstShow = true;
        listFilterPopup.MenuTreeElement.TreeView.NodeCheckedChanging += TreeView_NodeCheckedChanging;
    }
     
    private void TreeView_NodeCheckedChanging(object sender, RadTreeViewCancelEventArgs e)
    {
        if (e.Node.Text == "All")
        {
            if (isFirstShow)
            {
                isFirstShow = !isFirstShow;
                return;
            }
     
            Debug.WriteLine("All - " + !e.Node.Checked);
        }
    }

    You will notice there is a boolean flag which is needed because when the tree view is populated with the data from the current filter(s) the event is fired. This happens when the filter popup is opened. Another thing to note is that inside the NodeCheckedChanging event handling method the node Checked property has the old value and not the value that is about to be assigned to it.

    I hope this will be useful. Should you have further questions, I would be glad to help.

    Regards,
    Ivan Petrov
    Telerik
    RadChart for WinForms is obsolete. Now what?
  3. Peter
    Peter avatar
    2 posts
    Member since:
    Jun 2013

    Posted 06 Jun 2013 Link to this post

    Thank you for your reply:

    I used the Ok button on the filter menu:

      protected void RadGridView1FilterPopupInitialized(object sender, FilterPopupInitializedEventArgs e)
            {
               

                BaseFilterPopup select = (BaseFilterPopup)e.FilterPopup;
                FilterMenuButtonsItem filterMenuItem = new FilterMenuButtonsItem();

                foreach (var item in select.Items)
                {
                    if (item is FilterMenuButtonsItem)
                    {
                        filterMenuItem = (FilterMenuButtonsItem)item;
                    }
                }

    protected void FilterButtonOK_Click(object sender, EventArgs e)
      {
        // do something
    }

                filterMenuItem.ButtonOK.Click += FilterButtonOK_Click;
            }

Back to Top