2014-07-22 35 views
0

我正在计算Kendo UI DropDownList的计数,但我没有得到正确的价值。通过计算Kendo UI的数量,我想从Kendo DropDownList中删除最后一项。 我试着以下但不工作:获取Kendo UI的计数/长度/大小DropDownList

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); 

我越来越长为6,但我在DropDownList中共有13项。

2.

var len = dropDown.length; 

我越来越不确定。

+0

试试这个:-var下拉= $( “#RoleDrp”)的数据( “kendoDropDownList”)。 var lengthOfDropDown = dropDown.dataSource._data.length; –

回答

11

哎试试这个代码来获得剑道下拉列表的长度: -

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

感谢

+0

GR8。这是工作。谢谢......我搜遍了谷歌,但没有得到soln。为了移除项目,我只需要执行len-1。 – Dhwani