Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear all filters remove the custom filter options #4525

Closed
abhisb opened this issue Oct 15, 2015 · 3 comments
Closed

Clear all filters remove the custom filter options #4525

abhisb opened this issue Oct 15, 2015 · 3 comments

Comments

@abhisb
Copy link

abhisb commented Oct 15, 2015

When I click the clear all filters option from the table menu, filter data gets cleared and worked fine, but it has cleared the custom filter option I have added for two column fields. After then, custom filters are not working based on the conditions I have added. Please find the sample code I have created in Plunkr

In the provided sample code, age filters are working fine based on the filter conditions added. When selecting the clear all filters option, it clear all the filter text entered, after then text entered in age filter ie: greater than or less than is filtered based on default contains only and the custom filter I have added was not filtered anymore. It should be a major bug in business perspective.

@prathyushkp
Copy link

I am also facing same issue.
ui-grid.js is having a code to clear the filter ‘condition’ to ‘undefined’ when “Clear All Filter” option is selected from Grid Menu.

file: ui-grid.js

 var clearFilters = [{
        title: i18nService.getSafeText('gridMenu.clearAllFilters'),
        action: function ($event) {
          $scope.grid.clearAllFilters(undefined, true, undefined);
        },
        shown: function() {
          return $scope.grid.options.enableFiltering;
        },
        order: 100
      }];
      menuItems = menuItems.concat( clearFilters );

clearConditions argument value is always "true".

  Grid.prototype.clearAllFilters = function clearAllFilters(refreshRows, clearConditions, clearFlags) {
    // Default `refreshRows` to true because it will be the most commonly desired behaviour.
    if (refreshRows === undefined) {
      refreshRows = true;
    }
    if (clearConditions === undefined) {
      clearConditions = false;
    }
    if (clearFlags === undefined) {
      clearFlags = false;
    }

    this.columns.forEach(function(column) {
      column.filters.forEach(function(filter) {
        filter.term = undefined;

        if (clearConditions) {
          filter.condition = undefined;
        }

        if (clearFlags) {
          filter.flags = undefined;
        }
      });
    });

    if (refreshRows) {
      return this.refreshRows();
    }
  };

any solution to this issue?

@lebolo
Copy link
Contributor

lebolo commented Apr 26, 2016

Can probably close this issue and use #4657 instead.

@mportuga
Copy link
Member

Closed by #5361

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants