1
votes

I am using Ag-Grid Enterprise and have applied a set filter to a column, so far so good. I am using Server side row model and am pivoting data successfully on the backend (C# ASP.Net Core).

Once a user applies a filter to one column, I want the other column filters to be updated with a new list of available values that has been limited based upon the column filters that are set.

For example:

Colours:

  • Black
  • Orange
  • Red
  • Yellow
  • Blue

In Rainbow:

  • True
  • False

Now the idea is that when I set In Rainbow filter to True, I will update the Colours list to exclude black, the logic behind that is done on the C# side and thats fine, basically I fire a query to the server that will include In Rainbow = true, and it will return me an array of the colours that match this particular query.

So I can get the array of colours in javascript back and grab the filter successfully, i.e.

var data = ["Orange", "Red", "Yellow", "Blue"];

var filter = gridOptions.api.getFilterInstance(columnName);

However I cannot find a way to tell ag-grid that I have new values that I want to make available in the set list.

I have tried:

filter.setFilterValues(data);

and

filter.setModel({
     type: 'set',
     values: data
});

But neither appear to make changes to the set filter values that are available to select.

Any help on this would be greatly appreciated

1

1 Answers

0
votes

i'm not sure i completely understand your question but as far as i understand you want to set the values in you filter dynamically or something along these lines and if that's what you want i would suggest that you use filterParams. filterPramas has an attribute for value so it would go like this filterParams:{values:getvalues} get values will bet the function that will return the values you want there is the link to the filterParameters in ag-grid docs https://www.ag-grid.com/javascript-grid-filtering/#filter-parameters