Author Topic: Filter for multiple conditions within the same dataIndex  (Read 2608 times)

arborresearch

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 6
    • View Profile
Filter for multiple conditions within the same dataIndex
« on: March 24, 2017, 01:19:12 am »
I would like to know if it is possible to filter one column/dataIndex by multiple values at the same time. An example would be to filter for all last names that are either 'smith' or 'jones'. I have tried the code below without success

filterModel: { on: true, mode: "OR", header: true }
---------
$grid.pqGrid("filter", { oper: 'replace', data: [{ dataIndx: 'LastName', condition: 'contain', value: 'smith' }, { dataIndx: 'LastName', condition: 'contain', value: 'jones' }] })


Thank you!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Filter for multiple conditions within the same dataIndex
« Reply #1 on: March 24, 2017, 10:46:59 am »
Only one condition can be applied to a single dataIndx.

condition: 'range' or 'regexp' can be used for multiple matches within single column.

As an example https://paramquery.com/pro/demos/filter_header_local range condition can be used for Shipping region column.

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

arborresearch

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Filter for multiple conditions within the same dataIndex
« Reply #2 on: March 24, 2017, 08:21:31 pm »
Thank you for this information! The 'regexp' condition along with a pipe delimited value resolved my issue.

$grid.pqGrid("filter", { oper: 'replace', data: [{ dataIndx: 'LastName', condition: 'regexp', value: 'jones|smith' }