Author Topic: Header filter  (Read 2993 times)

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Header filter
« on: December 11, 2018, 02:39:52 pm »
When loading a state the values in the filter (range) seems to be limited to the matches found.
Can this be changed to always show all (turn cascading off)?

Use case could be when you want to change a filter in a saved state that is different from match.

Also, is there a way to convert old states (5.1.0) to work with 5.6.0?

« Last Edit: December 11, 2018, 04:06:18 pm by queensgambit9 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6260
    • View Profile
Re: Header filter
« Reply #1 on: December 11, 2018, 04:43:09 pm »
While loading a state, column filter values can be skipped by removing filter.crules from default value of stateColKeys

Code: [Select]
  stateColKeys : { filter: [ 'mode' ] }

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

state saved in 5.1.0 is structurally different from 5.6.0.
« Last Edit: December 11, 2018, 04:46:46 pm by paramquery »

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Header filter
« Reply #2 on: December 11, 2018, 05:03:06 pm »
Thanks, sorry if a bit unclear.

I do not want to remove the filter values. I am refering to the options in the filter dropdown.
They seem be locally loaded when the state is loaded. But I want the options from DB.

Ex:
col1, col2
value1, valuea
value2, valueb

Saving a state with with col1 filter = value1.
Available options for filter in col1 should now still have value1, value2 (not only value1).

Currently if you clear a column filter after loading a state the options are not updated from DB. Even though I have populated them from DB when creating the grid.
« Last Edit: December 11, 2018, 06:50:02 pm by queensgambit9 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6260
    • View Profile
Re: Header filter
« Reply #3 on: December 11, 2018, 09:32:44 pm »
loadState is called during create event ( synchronously ), and options are loaded from db asynchronously which occurs after load state anyway, so the problem shouldn't arise.

It can be verified by adding this

Code: [Select]
complete: function(){
        this.getColumn({dataIndx:'ShipRegion'}).filter.options = [{ShipRegion: 'China'}, {ShipRegion: 'Japan'}]
this.refreshHeader();
}

in this demo: https://paramquery.com/pro/demos/grid_state

I see the options in ShipRegion column filter as 'China' and 'Japan'.

Hope this helps.
« Last Edit: December 11, 2018, 09:39:20 pm by paramquery »

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Header filter
« Reply #4 on: December 12, 2018, 02:47:04 am »
Thank you.
I think the issue is that I use remote paging and have to select all distinct values to populate the options. I do this in create event currently...
But how do I instruct grid to always use the db options above and override the default that populate options based on the available data currently in grid?
« Last Edit: December 12, 2018, 03:04:33 am by queensgambit9 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6260
    • View Profile
Re: Header filter
« Reply #5 on: December 12, 2018, 07:36:38 am »
When filter options are assigned directly like column.filter.options = [...], those are instructions to the grid to always use those options instead of populating options based on the available data currently in grid. It doesn't matter whether it's local or remote paging.

Just ensure to assign filter options after loadState.

If you are facing issues please share a small test case via jsfiddle.
« Last Edit: December 12, 2018, 08:39:42 am by paramquery »

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Header filter
« Reply #6 on: December 12, 2018, 02:13:03 pm »
Thanks, works fine.
« Last Edit: December 12, 2018, 02:17:23 pm by queensgambit9 »