Hi, simple question, this filter is searching for rows matching “Canada” into the column “country”
grid.data.filter({ by: “country”, match: “Canada” });
What if i wanna search the rows that just “contains” Canada instead of being exact match?
Hi, simple question, this filter is searching for rows matching “Canada” into the column “country”
grid.data.filter({ by: “country”, match: “Canada” });
What if i wanna search the rows that just “contains” Canada instead of being exact match?
Hi Daniele_Cosenza,
filter
method accept a function to make the comparison:
grid.data.filter( item => item.country.indexOf("Canada") >=0 );
A more reusable and flexible approach is use the compare
property
const contains = (value, match) => value.indexOf(match) >= 0
// Now we can use contains with any field
grid.data.filter({ by: "country", match: "Canada", compare: contains })
// or dynamic criteria
grid.data.filter({ by, match, compare: contains })
esa es la idea
Thank you! I used this solution:
grid.data.filter( item => item.country.indexOf("Canada") != -1 );
And it works