Search code examples
javascriptkendo-uikendo-dropdown

Access additional fields at kendoDropDownList change event?


I need additional information associated to the selected item. how do I access to the additional fields at change event

var language = [
        {value: "English",  culture: "en-US", direction: "ltr", text: "English"},
        {value: "עברית",    culture: "he-IL", direction: "rtl", text: "עברית - Hebrew"},
        {value: "Français", culture: "fr-FR", direction: "ltr", text: "Français - French"}
    ];

$('#input').kendoDropDownList({
    'dataTextField': 'text',
    'dataValueField': 'value',
    'dataSource': language,
    'index': 0,
    'change': function (e) {
        // how do I access here to 'culture' and 'direction' fields
    }
});

Solution

  • You can use the dataItem method of the widget to retrieve the data for the selected item:

    'change': function (e) {
        var item = this.dataItem();
        // item.culture and item.direction
    }