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

Building fitler for 'startswith' for 0-9

1 Answer 64 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Trent Jones
Top achievements
Rank 1
Trent Jones asked on 28 Nov 2012, 02:41 PM
I am using MVC.
I am having some difficulty in creating a filter for a column 'Name' where startswith 0-9

grid.dataSource.filter([
    { field: "Name", operator: "startswith", value: "0" },
    { field: "Name", operator: "startswith", value: "2" },
    { field: "Name", operator: "startswith", value: "3" },
    { field: "Name", operator: "startswith", value: "4" },
    { field: "Name", operator: "startswith", value: "5" }
]);
Above is abbrieviated....
Basically i have a text field 'Name' and i need to show any record that starts with 0-9.

Seems like no matter which way i phrase the filter, the filter on the DataSourceRequest never haves more that two filters (CompositeFilter).

Any help would be great. thanks.  Logically i know i could have ten colums and filter by all ten columns for some value so my feeling is internally it is grouping by "Name" b/c the demos only support two filters per column.

-Trent

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 29 Nov 2012, 09:13 AM
Hi,

 By default the filter method uses "and" as the filtering logic. You should specify that you need "or":

dataSource.filter({
    logic: "or",
    filters: [
      { field: "orderId", operator: "eq", value: 10248 },
      { field: "customerName", operator: "startswith", value: "Paul" }
    ]
});

You can find more info in the DataSource API documentation.

All the best,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Trent Jones
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or