Clear items in DropDownList

1 Answer 7168 Views
DropDownList
Rich
Top achievements
Rank 1
Rich asked on 30 Oct 2012, 04:57 PM
Hi All, i cannot figure this out.

I have a dropdownlist with a datasource. I need to clear the items in the list to sort of initialize it after someone makes an selection and some other things happen..

How can i clear the items in the list? Clear them from the datasource? thanks.

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 31 Oct 2012, 04:01 PM
Hello Rich,

You can use:

var ddl = $("#clientid").data("kendoDropDownList");
ddl.dataSource.data([]); // clears dataSource
ddl.text(""); // clears visible text
ddl.value(""); // clears invisible value

Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Chuck
Top achievements
Rank 1
commented on 09 Sep 2014, 09:29 PM


I use that exact code:
var ddl = $("#ddlSubAction").data("kendoDropDownList");
ddl.dataSource.data({});

But instantly recive an error that states that the object does not support the property or method 'slice'
Dimo
Telerik team
commented on 10 Sep 2014, 09:38 AM

Hello Chuck,

You are probably using a newer Kendo UI version. In this case, please provide an empty array argument instead of an empty object.

Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
nhat
Top achievements
Rank 1
commented on 23 Feb 2019, 08:29 AM

ddl.dataSource.data([]);

Nithya
Top achievements
Rank 1
commented on 27 Sep 2019, 09:09 PM

var dropdownlist = $("#Merchant").data("kendoDropDownList");
                dropdownlist.enable(false); // Disable the dropdownlist
         
            $("#Merchant").data("kendoDropDownList").value(null); // Clear the value 
Tags
DropDownList
Asked by
Rich
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or