Building fitler for 'startswith' for 0-9

2 posts, 0 answers
  1. Trent Jones
    Trent Jones avatar
    49 posts
    Member since:
    Aug 2009

    Posted 28 Nov 2012 Link to this post

    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
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 29 Nov 2012 Link to this post

    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!
Back to Top