Author Topic: Filter condition  (Read 2894 times)

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Filter condition
« on: November 16, 2016, 02:28:29 pm »
Hi, Im using:

Code: [Select]
$("#grid_array").pqGrid( "filter", { oper: 'replace', data: [
            { dataIndx: 'Column1', condition: 'equal', value: '0'},
            ]})

to set a filter...Would it be possible to add expression OR like 'Column1' == '0' OR 'Column2' == '0'?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6121
    • View Profile
Re: Filter condition
« Reply #1 on: November 16, 2016, 02:35:15 pm »
That would be

grid.filter({
    oper: 'replace',
    data: [
          { dataIndx: 'Column1', condition: 'equal', value: '0'},
          { dataIndx: 'Column2', condition: 'equal', value: '0'}
    ]
});

and set mode = "OR" in filterModel

http://paramquery.com/pro/api#option-filterModel

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Filter condition
« Reply #2 on: November 16, 2016, 06:30:19 pm »
Thanks, works fine.

Question...since I change the filterModel from default (AND) to (OR), I would like to restore after the filter is executed:

Code: [Select]
$("#grid_array").pqGrid( "option", "filterModel", { on: true, mode : "AND" } );
However this removes the filter header?

Also, regarding the filter condition...if I for the same column would like to filter on value: 1, 2 and 4...how would that looke like?
Code: [Select]
{ dataIndx: 'test', condition: 'equal', value: '0'}, // add value 1, 2 and 4...
 

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6121
    • View Profile
Re: Filter condition
« Reply #3 on: November 16, 2016, 08:11:50 pm »
Quote
$("#grid_array").pqGrid( "option", "filterModel", { on: true, mode : "AND" } );

However this removes the filter header?

use $("#grid_array").pqGrid( "option", "filterModel.mode", "AND" );


Quote
if I for the same column would like to filter on value: 1, 2 and 4...how would that looke like?
Code: [Select]
{ dataIndx: 'test', condition: 'equal', value: '0'}, // add value 1, 2 and 4...

use { dataIndx: 'test', condition: 'range', value: [1,2,4] },

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Filter condition
« Reply #4 on: November 17, 2016, 08:17:07 pm »
Thanks. Is it possible to have more advanced expressions?

Code: [Select]
$("#grid_array").pqGrid("filter", {
oper: 'replace', data: [
    { dataIndx: 'Indx1', condition: 'equal', value: '1'},
    { dataIndx: 'Indx2', condition: 'equal', value: '2'},
    { dataIndx: 'Indx3', condition: 'equal', value: '3'}
]});

Like:
((Indx1 == '1' OR Indx2 == '1') AND Indx3 == '1') ?


queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Filter condition
« Reply #5 on: November 24, 2016, 06:46:38 pm »
Would the above be possible?
Thanks.


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6121
    • View Profile
Re: Filter condition
« Reply #6 on: November 24, 2016, 06:56:20 pm »
Such conditions are not supported.