0
votes

I want to display the current filters selected by the user. So I'm getting the filter model using the onFilterChanged callback function:

onFilterChanged(params) {
    const filterModel = this.gridApi.getFilterModel();
    console.log(filterModel);
  }

Everything works fine except for a scenario, where we filter the first and column and try to filter the second column. For example, if you see in the plunker example:

https://plnkr.co/edit/X6LlP2XIOaEeeW7I?preview

I filter the first column as Michael Phillips and Abhinav Bindra, then I get the filterModel as

athlete:
    filterType: "set"
    values: Array(2)
        0: "Abhinav Bindra"
        1: "Michael Phelps"
        length: 2

which is correct. Then I try to filter the second column, country, then I get the filterModel as

athlete:
    filterType: "set"
    values: (2) ["Abhinav Bindra", "Michael Phelps"]
country: {values: Array(109), filterType: "set"}

Which is incorrect. As I'm expecting to get the country value as either India or the USA and not the whole array of 109 countries.

Interestingly, the filter UI displays only these 2 countries India and the USA as checkboxes.

How do I get hold of the correct filter model, so that I can show in my custom component?

Edit: If I use the floating filter component, then the values are displayed correctly in the floating filter. I want to get the model for that floating filter component. Floating Filter

Any pointers would be highly appreciated.
Thanks in Advance!!

1

1 Answers

0
votes

Use gridOptions.api.getFilterInstance('gold').getValueModel().availableValues to get all the available values.

gridOptions.api.getFilterInstance('your column name here').check out the screenshot below.

here is the screenshot explaining getvalumodel