2014-07-22 37 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