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

Filtering gridview winfroms - how to select all

2 Answers 79 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 03 Jun 2013, 01:52 PM
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 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 06 Jun 2013, 09:28 AM
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?
0
Peter
Top achievements
Rank 1
answered on 06 Jun 2013, 12:59 PM
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;
        }

Tags
GridView
Asked by
Peter
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Peter
Top achievements
Rank 1
Share this question
or