Author Topic: How do I get the filter values  (Read 350 times)

jplevene

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 126
    • View Profile
How do I get the filter values
« on: April 25, 2024, 09:04:32 pm »
I need to get the values entered for all active filters on the grid, so if someone has set the "name" column and "location" column filters, I need the column dataIndx with the appropriate filter values.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6296
    • View Profile
Re: How do I get the filter values
« Reply #1 on: April 25, 2024, 09:59:02 pm »
Information of filtered state can be obtained in beforeFilter and filter events.

The structure of ui argument in both events is same as parameters passed to the filter method.

https://paramquery.com/pro/api#event-beforeFilter

https://paramquery.com/pro/api#event-filter

https://paramquery.com/pro/api#method-filter

jplevene

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 126
    • View Profile
Re: How do I get the filter values
« Reply #2 on: April 26, 2024, 11:06:25 pm »
You misunderstood.  I wanted to get the filter values at any time, not after or before they are changed. 

The user does something completely separate from the table and I need to find what the currently set filter values are.  I could just save filter settings on the events you mentioned and then look that up when I need it, but it seems long winded and a lot of unnecessary work when all I want are the column names with the current filter value.

I also need to find which column has the current order and if it is asc or desc.

The issue is that I am having to create a very "unique" virtual scrolling paging method and have to load the data outside of the grid, then add certain rows to the grid.  As the data loading is completely separate from the grid, I need to know the column that is sorting and all the columns with a filter on them.

There is no way to do the data loading directly in the grid, I'm having to move away from that for this particular grid only.
« Last Edit: April 26, 2024, 11:26:14 pm by jplevene »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6296
    • View Profile
Re: How do I get the filter values
« Reply #3 on: April 29, 2024, 01:52:46 pm »
You are right, the UI argument of filter event can be saved and can be looked up at any time. It provides complete information about filtered column name (dataIndx), multiple filter conditions and filter values for each filtered column.

Alternatively the colModel can be iterated and filter property of every column can be read to get complete filter information.

For sorting, the sortModel.sorter property provides the required sorted columns information.

https://paramquery.com/pro/api#option-sortModel