Search code examples
htmlkendo-uikendo-multiselect

Kendo multiselect


All the example and uses of Kendo UI Multiselect I've seen so far use 'id' instead of 'class' name in the html

I tried using class name but it doesn't seem to work. Am I doing something wrong or Kendo doesn't support this?

HTML:

<select class="multiselect" kendo-multi-select k-options="selectOptions">

Scipt:

const multiselect = $(".multiselect").data("kendoMultiSelect");
const value = multiselect.value();

This is the error I get:

TypeError: Cannot read property 'value' of undefined

Solution

  • You will need to use a more specific selector because the controls are wrapped.

    var mymultiselect = $(".multiselect[data-role=multiselect]");
    
    mymultiselect.each(function(idx, input) {
         var myselect= $(input).data("kendoMultiSelect");
    
         alert("Value: " + myselect.value() );
    })