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

How can I programmatically clear the DropDownList filter?

4 Answers 2118 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Johnathan
Top achievements
Rank 1
Johnathan asked on 19 Jun 2015, 09:46 PM

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"?

4 Answers, 1 is accepted

Sort by
0
Plamen Lazarov
Telerik team
answered on 23 Jun 2015, 08:25 AM

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!
 
0
Johnathan
Top achievements
Rank 1
answered on 23 Jun 2015, 12:57 PM
That worked perfectly!  Thank you so much!
0
Neil
Top achievements
Rank 1
answered on 07 Mar 2020, 07:38 AM

Is there any example here that actually reads from a table in database?..

Because I've been missing something here. I am getting null values in my parameter. 

I have this:

   dataTextField: 'userName',
   dataValueField: 'userId',

 

How do I actually tell my function to get the value?

 ReadUser(string text, string userName, string value)

Here's my function, and it is always null.. What did i miss?.. just give an example.

0
Dimitar
Telerik team
answered on 10 Mar 2020, 12:54 PM

Hello Neil,

Kendo UI DropDownList demos retrieve data from a service and its code is available on GitHub. An alternative of its code may be found in the demos of DropDownList for Telerik UI for ASP.NET MVC, e.g. Binding to remote data, Server filtering. They show how to retrieve data withing the Controller. The code is available in demo's Source code viewer.

Regards,
Dimitar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DropDownList
Asked by
Johnathan
Top achievements
Rank 1
Answers by
Plamen Lazarov
Telerik team
Johnathan
Top achievements
Rank 1
Neil
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or