Search code examples
kendo-uikendo-asp.net-mvckendo-multiselect

Get other fields in Kendo MultiSelect Change event


I'd like to update a label on change event of the Kendo Multi Select. But the value() just gives the Id. Do you have any idea about accessing other fields of the selected value?

This is the JavaScript handler:

function change(e) {
    if (e.sender.value()[0])
        $("#Label").text(e.sender.value()[0]);
    else
        $("#Label").text('');
}

Solution

  • Use var value = this.dataItems(); instead, it will give you all information you need about the current selected value, and do note because it's multi select it's value may more than 1.

    function onChange(e) {
        var value = this.dataItems();
        console.log(value[0].text);
        if (value[0]){
            $("#Label").text(value[0].text);
        }else{
            $("#Label").text('');
        }
    }
    

    DEMO