1

I want to filter all columns in the data grid based on or condition. For a single column(name) filter I tried below function and it's working properly.

grid.filter( {name: "*" + value + "*" } );

Now I want to use this filter for multiple columns on grid, I tried below code but that is not working:

grid.filter({name:"*" + value + "*"} || {solution:"*" + value + "*"});

Please help me with suitable code for multiple column filter on grid. I am using Dojo 1.8.1.

2 Answers 2

0

Create hidden column for filtering purposes and put in concatenated data you want to be filtered.

If your data for datastore are:

data=[
{ name: "smartphone", solution: "use iPhone instead iPod"},
{ name: "tablet",     solution: "use iPad instead iPod"},
{ name: "iPad",       solution: "use it"}
]

add column forFiltering with concatenated data of other columns:

data=[
{ name: "smartphone", solution: "use iPhone instead iPod", forFiltering: "smartphone use iPhone instead iPod"},
{ name: "tablet",     solution: "use iPad instead iPod",   forFiltering: "tablet use iPad instead iPod"},
{ name: "iPad",       solution: "use it",                  forFiltering: "iPad use it"}
]

and then do filtering on that column:

grid.filter({forFiltering:"*" + value + "*"});
2
  • Please give a coding example if you can.
    – ouflak
    Commented Jan 19, 2015 at 8:21
  • @dori-naji solution is for: 'condition1 and condition2', Swpno asks for: 'value is in field1 or in field2' Commented Jan 19, 2015 at 17:54
0

IF I understand your question correctly, you can simply separate the two arguments for the filter with a comma. so instead of grid.filter({name:"*" + value + "*"} || {solution:"*" + value + "*"});

you should use grid.filter({name:"*" + value + "*",solution:"*" + value + "*"} );

you can check this working example in jsfiddle

Not the answer you're looking for? Browse other questions tagged or ask your own question.