<script type="text/javascript">
function buttonclick(){
var target = $('#skillsets').data("ejDropDownList"); // accessing the control's instance
alert("Number of items: "+target.getListData().length); //accessing number of items from getListData method
}
</script> |
I tried that and get this error:
I tried grp1.getListData.length (without paras) but the value is always 0.
<script >
var grp1 = $('#ddlBUGrp2').data("ejDropDownList"); // accessing control's instance
var x = ej.isNullOrUndefined(grp1.getListData()) ? 0 : grp1.getListData().length; //if the getListData is undefined, then return 0.
</script> |
That works, but now run into another interesting thing:
var grp2 = $("#ddlBUGrp2").data("ejDropDownList");
$('#ddlBUGrp2').ejDropDownList({ dataSource: data}); //data is a list with say 4 items
var numItems1 = ej.isNullOrUndefined(grp2.getListData()) ? 0 : grp2.getListData().length; //numItems1 = 4 which would be correct
$('#ddlBUGrp2').ejDropDownList({ dataSource: null});
var numItems2 = ej.isNullOrUndefined(grp2.getListData()) ? 0 : grp2.getListData().length; //numItems2 still = 4 shouldn't it be 0;
Mike
<script type="text/javascript">
var grp2 = $("#ddlBUGrp2").data("ejDropDownList");
$('#ddlBUGrp2').ejDropDownList({ dataSource: data});
var numItems1 = grp2._getLi().length;
$('#ddlBUGrp2').ejDropDownList({ dataSource: null});
var numItems2 = grp2._getLi().length;
</script>
|
Hi Michael
Thank you for contacting Syncfusion forums.
You can get the total number of items in a DropDownList from the getListData method. Kindly refer to the following code snippet.
<script type="text/javascript">function buttonclick(){var target = $('#skillsets').data("ejDropDownList"); // accessing the control's instancealert("Number of items: "+target.getListData().length); //accessing number of items from getListData method}</script>
Kindly refer to the following playground sample: http://jsplayground.syncfusion.com/qjpiump4
Regards,Prince