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

And with Or filters on MVC Grid (client side)

1 Answer 428 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 20 Jul 2017, 09:12 AM

We currently filter some MVC grids on the client (this works well for us) however a new requirement is to filter on a value in ONE column, and if value appears in a set of other columns.

E.G. 

A + (B or C or D)

current we filter like this on the "A" column 

grid.dataSource.filter({
       logic: "or",
      filters: [
          { field: "SkillStatus", operator: "contains", value: "D" }
          ]
});

and this is how we filter on the B,C & D columns 

grid.dataSource.filter({
                logic: "or",
                filters: [
                    { field: "SkillName", operator: "contains", value: val },
                    { field: "SkillCode", operator: "contains", value: val },
   
                { field: "SkillDesc", operator: "contains", value: val },

                    ]
            });

Is there a way to apply both these filters to one grid, such that 

A   | B   | C    | D   |
1   | X    | Y    | X   |
1   | Y    | X    | X   |
2   | Z    | Z    | Z   |
2   | Y    | Y    | Z   |

A = 1 , "Other Value" = X  returns
A   | B   | C    | D   |

1   | X    | Y    | X   |
1   | Y    | X    | X   |

A = 1 , "Other Value" = Z  returns
A   | B   | C    | D   |

(no records)

A = 2 , "Other Value" = Z  returns

A   | B   | C    | D   |
2   | Z    | Z    | Z   |
2   | Y    | Y    | Z   |

A = 2 , "Other Value" = X  returns
A   | B   | C    | D   |

(no records)

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 21 Jul 2017, 01:55 PM
Hi Simon,

I have assembled small sample which illustrates how to use And with Or filters client-side:



Regards,
Georgi
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Simon
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or