How can I programmatically clear the DropDownList filter?

3 posts, 0 answers
  1. Johnathan
    Johnathan avatar
    3 posts
    Member since:
    Mar 2015

    Posted 19 Jun 2015 Link to this post

    I am using Javascript and have a kendo drop down list like so:

    $("#ddl).kendoDropDownList({
    dataTextField: "name",
    dataValueField: "id",
    filter: "contains",

    dataSource: {
        data: [
          {id: 1, name: "apples"},
          {id: 2, name: "oranges"},
          {id: 3, name: "apples2"},
          {id: 4, name: "oranges2"}]
      }
    });

     

    As a user, I open the drop down list, type "apples" into the filter, and select "apples".  Then I activate a function (though clicking a button), that attempts to programmatically change the drop down list to the "oranges" value (index 1, id 2).  However, the filterInput is still active, and attempts to set the drop down list to index 1 instead sets it to index 1 of the filtered drop down list ("apples2").

    I know I can access the filterInput programmatically.  How can I programmatically clear the filterInput and set the drop down list value to "oranges"?

  2. Plamen Lazarov
    Admin
    Plamen Lazarov avatar
    135 posts

    Posted 23 Jun 2015 Link to this post

    Hello,

    In order to clear the filter input get an instance of the widget and clear the filter of it's dataSource first.

    ddl.dataSource.filter("")
    Please refer to the demo below which illustrates this approach.

    http://dojo.telerik.com/@plazarov/EmAni

     

    Regards,
    Plamen Lazarov
    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
  4. Johnathan
    Johnathan avatar
    3 posts
    Member since:
    Mar 2015

    Posted 23 Jun 2015 in reply to Plamen Lazarov Link to this post

    That worked perfectly!  Thank you so much!
Back to Top