Frage

At the moment I can only store 'dataTextField' and 'dataValueField' to a Kendo DropDown list, but I need to be able to store more values for each item in the list.

I populate the Drop downs with JSON data, the JSON array contains multiple properties for each index in the array.

Is there a way to add more values for drop down items (e.g. 'dataCustomField1', 'dataCustomField2', 'dataCustomField3')

War es hilfreich?

Lösung

I found the solution.

var dropDown = $("#ddList").data("kendoDropDownList"); 
var ddData = dropDown.dataSource.view()[dropDown.selectedIndex - 1];

ddData contains all the JSON of the selected item in the drop Down.

Andere Tipps

I know the above selected answer works but the value you're looking for is already given to you when item is selected in the drop list as below

$('#drop-list').kendoDropDownList({
     dataSource: [{ID: 1, NAME: 'A', dataCustomField1: 'data'}...],
     dataTextField: "NAME",
     dataValueField: "ID",
     change: function(e) {
         var myJsonItem = this.dataItem();          // <---- Here is your json item
         console.log(myJsonItem.dataCustomField1);  // <---- Sample usage
     }
});
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top