ComboBox Filtering

2 posts, 1 answers
  1. Yuan
    Yuan avatar
    9 posts
    Member since:
    Jul 2014

    Posted 07 Jan 2015 Link to this post

    Out of the box, the ComboBox supports filter values are startswith, endswith and contains. Our requirement needs a more complex filtering mechanism. Our data source will be something looks like 
    [{name: "Pennsylvania State University", id: 1}, {name: "University of Pennsylvania", id: 2}, {name: "Princeton University", id: 3}]
    When user enters "penn univ", we want the filter result to be 
    [{name: "Pennsylvania State University", id: 1}, {name: "University of Pennsylvania", id: 2}]
    This needs a dynamically generated filter like
    { logic: "and",
      filters:[{ field: "name", operator: "contains", value: "penn"},
        { field: "name", operator: "contains", value: "univ"}
      ]
    }
    Is it possible for us to pass a function which returns such a filter with a dynamically generated filter array inside? Or is it has to be predefined string? If we can, how do we split the user input into string array and pass the parts in as value respectively? 
    Is it possible to capture the keyup event of the input, and filter the data source separately?
  2. Answer
    Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 09 Jan 2015 Link to this post

    Hello Yuan,

    You can use the filtering event of the widget. It allows to prevent the started filter action and perform a custom one based on your custom requirements. Refer to the datasource filter method for more details about data filtration.

    Regards,
    Georgi Krustev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top