This is a migrated thread and some comments may be shown as answers.

Unable to select multiple items programatically

2 Answers 501 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Claudia
Top achievements
Rank 1
Claudia asked on 26 Feb 2020, 09:07 PM

Hi

I'm using a multiselect and trying to select 2 values programmatically but only the first is really showing. Here is a piece of code of what i'm doing.

var multi= $("#pilotProgram").data("kendoMultiSelect");

multi.value(["1", "2"]);
multi.trigger("change");

Thank you

2 Answers, 1 is accepted

Sort by
0
Claudia
Top achievements
Rank 1
answered on 27 Feb 2020, 02:33 PM

Hi

I also tried the filter part

$("#pilotProgram").kendoMultiSelect({
       dataSource: [
           { value: "1", text: "Option A", isDeleted: false },
           { value: "2", text: "Option B", isDeleted: false },
           { value: "3", text: "Option C", isDeleted: false },           
           { value: "4", text: "Option D", isDeleted: false },
           { value: "5", text: "Option E", isDeleted: false }
       ],
       dataTextField: "text",
       dataValueField: "value",       
       select: function (e) {
           if (e.dataItem.isDeleted) {
               e.preventDefault();
           }
       },
       change: function (e) {
           assObserv.dataSource.data()[0].pilotProgram = this.dataItem();
       }
   });
    
   //This part is inside change event of the observable (assObserv)
    var pilotMulti = $("#pilotProgram").data("kendoMultiSelect");
    pilotMulti.dataSource.filter({});
    pilotMulti.value(["1", "2"]);
    pilotMulti.trigger("change");

Thank you

 

 

0
Claudia
Top achievements
Rank 1
answered on 27 Feb 2020, 08:47 PM
Found the issue I put dataItem() instead of dataItems(). Now is working fine, thank you and sorry for the confusion
Tags
MultiSelect
Asked by
Claudia
Top achievements
Rank 1
Answers by
Claudia
Top achievements
Rank 1
Share this question
or