This is a migrated thread and some comments may be shown as answers.

Multiple client-side filter expressions?

1 Answer 30 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Basem
Top achievements
Rank 1
Basem asked on 26 Apr 2012, 10:52 PM
I am filtering client-side using the below syntax:

var filterExpr = { field: 'Name', operator: 'substringof', value: value };
stopsGrid.dataSource.filter(filterExpr);

How do I add an "or" expression to this? I want to also check if value exists in the "Description" field. Thanks for any help.

1 Answer, 1 is accepted

Sort by
0
Vesselin Obreshkov
Top achievements
Rank 2
answered on 08 Oct 2012, 06:33 PM
Try this:

var filterExpr = {
    logic = "or|and",
    filters: [
        { field: "<field_name>", operator: "eq", value: <your_value> }, // filter A
        { field: "<field_name>", operator: "neq", value: <your_value> } // filter B
    ]
};

 This would give you a simple "A and|or B" query. If you need to link more filters, you need to do something like this:

var filterExpr = {
    logic = "and",
    filters: [
        { field: "<field_name>", operator: "eq", value: <your_value> }, // filter A
        { logic: "or", filters: [
            { field: "<field_name>", operator: "eq", value: <your_value> }, // filter B1
            { field: "<field_name>", operator: "eq", value: <your_value> }  // filter B2
        ]}
    ]
};

This would give you "A and (B1 or B2)".
Tags
Grid
Asked by
Basem
Top achievements
Rank 1
Answers by
Vesselin Obreshkov
Top achievements
Rank 2
Share this question
or