Author Topic: Filter options  (Read 3012 times)

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Filter options
« on: April 04, 2019, 07:30:23 pm »
I have celldata like: value1, value2 etc for a specific column...I would the options (range) in the filter to be populated as available celldata split by comma (,)...so option list becomes:

value1
value2 etc

Then use a custom built filter for range where it compares with contain condition.

I use remote data and filtermodel.
How do I assign the options in best way?
« Last Edit: April 04, 2019, 07:58:36 pm by queensgambit9 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: Filter options
« Reply #1 on: April 04, 2019, 11:01:55 pm »
Do you also use remote paging?

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Filter options
« Reply #2 on: April 05, 2019, 01:22:38 am »
Yes.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: Filter options
« Reply #3 on: April 05, 2019, 04:29:00 pm »
Options can't be created locally for remote paging because data in grid is for current page only.

You need to create the options remotely and assign them to column.filter.options in an ajax call.
« Last Edit: April 05, 2019, 04:46:46 pm by paramquery »

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Filter options
« Reply #4 on: April 12, 2019, 01:20:25 pm »
After I get the response from ajax call I assign them as:

Code: [Select]
grid.getColumn({ dataIndx: key }).filter.options = response[ key ];
But I need to manipulate the values before assigning them (each , separated value as own option).

Ex of array element:

Code: [Select]
{col1: "value1, value2, value3"}...I need the as single array elements {col1: "value1} etc

How would I best do this?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6265
    • View Profile
Re: Filter options
« Reply #5 on: April 12, 2019, 07:13:53 pm »
This is a data structure related question. ( not directly related to grid )

First you have to get all the values ( from all objects in array ) in a single array and then get unique values.

https://stackoverflow.com/questions/38206915/filter-out-array-to-have-only-unique-values/38206980

and reconvert it into

[{col1: val1}, {col1: val2}, ...]

format.