How to retrieve all data of a kendo ui dropdown list?

爱⌒轻易说出口 提交于 2019-12-05 07:48:49

Can you try :

var data = $("#dropDownList").data("kendoDropDownList");

Try this it will retrive all values from Kendo dropdown.

var values = [];
    var grid = $("#SampleDropdown").data("kendoDropDownList");

    var ds = grid.dataSource;
    var len = ds._data.length;
    if (len > 0) {
        var i;

        for (i = 0; i < len; i++) {
            var val = ds._data[i].Value;
            values.push(val);
        }
      }

Try this.

 var values = [];
    var data = $("#dropDownList option").each(function(){
  values.push($(this).val());
  });

If you want the actual DataItems from the DDL you can get them by Viewing the DataSource:

$("#dropDownList").data("kendoDropDownList").dataSource.view()

You can then also find individual items easily by id if you need to:

$("#dropDownList").data("kendoDropDownList").dataSource.view().find(x=>x.Value === 'ID')

Simple one liner.

To get all data items:

$("#myDDL").data("kendoCombo").dataSource.data();

To get single property value:

$("#myDDL").data("kendoCombo").dataSource.data()[0].ProductId;

Reference

$("#dropDownList").data('kendoDropDownList').options.optionList - returns object with values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!