Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
Webdatagrid - Data filtered event doesn't update filtered columns
posted

Hello folks,

I need to track the currently selected column filters.

Firstly, I attach the DataFiltered event to my webdatagrid like so:

dtPlanningWin10Migration.Behaviors.Filtering.DataFiltered += Filtering_DataFiltered;

In the event I save the filters after the grid data have been filtered:

   private void Filtering_DataFiltered(object sender, FilteredEventArgs e)
   {
               ColumnFilters        CurrentGridColumnFilters = e.ColumnFilters;
   }

Here I store all filters that are currently selected by the user.

The issue is that if a user clicks on "Clear filter" in the filter options of the grid, the column is still present in the e.ColumnFilters list. Why hasn't it been removed automatically from the list? How can I detect if the filter column has been cleared or not?

Thanks and all the best,

Flo

Parents
  • 2580
    Offline posted

    Hello Flo,

    Thank you for contacting Infragistics Support.

    When you click "Clear filter", what you get in e.ColumnFilters is one filter with RuleType "All" and an empty value. Basically this means the filter is cleared.

    If you want to check whether the filters are cleared, here is the code:

    protected void WebDataGrid1_DataFiltered(object sender, FilteredEventArgs e)
        {
            WebDataGrid wdg = sender as WebDataGrid;
            ColumnFilter cf = e.ColumnFilters.GetFilter("ProductName");
            RuleTextNode rtn = (cf.Condition as RuleTextNode);
            TextFilterRules rule = rtn.Rule;
            string vl = rtn.Value;
            if (rule == TextFilterRules.All && vl == string.Empty)
            {
                // the col filter is clear
            }
        }

    Here is a sample as well - link.

    Please let me know if you need further help.

Reply Children