Get Count/Length/Size of Kendo UI DropDownList
Asked Answered
E

1

5

I am tring to get count of Kendo UI DropDownList but I am not getting right value. By taking count of Kendo UI, I want to remove last item from Kendo DropDownList. I tried following but not working:

1.

var dropDown = $("#RoleDrp").data("kendoDropDownList");
var len = dropDown.value().length+1;
var itemToRemove = dropDown.dataSource.at(len);
dropDown.dataSource.remove(itemToRemove);
dropDown.select(0);

I am getting length as 6 but I have total 13 items in DropDownList.

2.

var len = dropDown.length;

I am getting undefined.

Exsiccate answered 22/7, 2014 at 4:15 Comment(2)
try this :-var dropDown = $("#RoleDrp").data("kendoDropDownList"); var lengthOfDropDown=dropDown.dataSource._data.length;Schell
you shouldn't access _ variables directly in kendo controls unless you're in the console debugger. Use the getter. You don't know if you have access to it or not as it could be scoped.Armpit
S
19

hey try this code to get length of kendo dropdown list:-

var dropDown = $("#RoleDrp").data("kendoDropDownList");
var len =dropDown.dataSource.data().length;
alert(len);

Thanks

Schell answered 22/7, 2014 at 4:24 Comment(1)
GR8. It is working. Thanks... I searched all over google but didnt get soln. For removing item I just have to do len-1.Exsiccate

© 2022 - 2024 — McMap. All rights reserved.