javascript 获取 Kendo UI DropDownList 的数量/长度/大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24878816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 03:29:55  来源:igfitidea点击:

Get Count/Length/Size of Kendo UI DropDownList

javascriptjqueryasp.net-mvckendo-uikendo-dropdown

提问by Dhwani

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:

我想计算 Kendo UI DropDownList 的数量,但我没有得到正确的值。通过计算 Kendo UI,我想从 Kendo DropDownList 中删除最后一个项目。我尝试了以下但不起作用:

1.

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.

我得到的长度为 6,但我在 DropDownList 中总共有 13 个项目。

2.

2.

var len = dropDown.length;

I am getting undefined.

我越来越不确定了。

回答by Devendra Soni

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

谢谢