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

Kendo UI Grid Multiple Filters

3 Answers 49 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kannyetta
Top achievements
Rank 1
Kannyetta asked on 23 Jul 2015, 08:38 PM

Hi, I am using a kendo UI grid and have multiple filters for status -  closed, cancelled, finished. In order for me to remove one of the filters and not see the extra 'and' logic in html above the grid, I have to make the method call for removal twice or click the 'x' to remove the filter twice. I am not sure what is causing this behavior and any help will be appreciated. 

 

Here is the method call:

       var newfilter = removeFilter(existingFilters, $(param).attr('data-field'), $(param).attr('data-operator'), $(param).attr('data-value'));

 

Here is the  removeFilter method:

function removeFilter(filter, field, operator, value) {

  if (filter == null)
      return [];

  for (var i = 0; i < filter.length; i++) {
    if (filter[i].filters != null && filter[i].filters.length >= 0) {
      if (filter[i].filters.length == 0) {
          filter.splice(i, 1);
        return removeFilter(filter, field, operator, value);
      }

      filter[i].filters = removeFilter(filter[i].filters, field, operator, value);
    }
    else {
      if (filter[i].field == field && filter[i].operator == operator && filter[i].value.toString() == value) {
        filter.splice(i, 1);
        return removeFilter(filter, field, operator, value);
      }
    }
  }

  return filter;
}

 Here is the html method to display the filter:

function gridFilter(gridSelector, filter) {
  if (!filter) return '';

  var html = '';

  if (filter.filters) {
      for (var i = 0; i < filter.filters.length; i++) {
          if (filter.logic && i > 0)
          {
                      html += '<span class="op">' + filter.logic + '</span>';
          }

        if ($.isArray(filter.filters[i].filters))
            html += gridFilter(gridSelector, filter.filters[i]);
       else
        html += '<span class="param" data-field="' + filter.filters[i].field + '" data-operator="' + filter.filters[i].operator + '" data-value="' + filter.filters[i].value + '">' + formatField(gridSelector, filter.filters[i].field) + ' ' + formatOperator(filter.filters[i].operator) + ' ' + formatValue(filter.filters[i].value) + '<span class="remove">&times;</span></span>';
    }
  }

  return html;
}

 

Thanks!

Kann

3 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 27 Jul 2015, 04:04 PM
Hi,

If I understood correctly you would like to remove the extra filter input and filter logic DropDownList from the filter menu.

This can be configured through the options, please set filterable.extra to false.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Kannyetta
Top achievements
Rank 1
answered on 27 Jul 2015, 04:10 PM

I do need to remove the extra filter but this is a custom filter. I need to remove Cancelled from the filter list. It does not get removed. I have to click the 'x' twice or add code to call the removeFilter function. See attached file.

 

Thanks

Kann

0
Alexander Valchev
Telerik team
answered on 29 Jul 2015, 10:42 AM
Hi Kannyetta,

Removing specific filters that were added through an external form is not supported out of the box. I am afraid that while this behavior could be achieved, it requires a custom solution that is beyond the scope of our support services.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Kannyetta
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Kannyetta
Top achievements
Rank 1
Share this question
or