Kendo ui Multi Select Remove Selected element using value -


i using kendo ui multiple select

http://demos.kendoui.com/web/multiselect/events.html

i have code

var data =         [             { text: "africa", value: "1" },             { text: "europe", value: "2" },             { text: "asia", value: "3" },             { text: "north america", value: "4" },             { text: "south america", value: "5" },             { text: "antarctica", value: "6" },             { text: "australia", value: "7" }         ];  var multi = $("#select").kendomultiselect({     datatextfield: "text",     datavaluefield: "value",     datasource: data }).data("kendomultiselect"); 

now can add values using this

multi.value(["5", "3"]); 

now want remove selected values

is there way remove values using value or text

for example if want remove 5 there method multi.remove(["5"]);

or other way remove it???

for removing element multiselect programmatically, can use:

// elements removed var subtract = ["1", "5"]; // copy of current selected elements var values = multi.value().slice(); // remove elements subtract values = $.grep(values, function(a) {     return $.inarray(a, subtract) == -1; }); // clean filtering multi.datasource.filter({}); // set new values multi.value(values); 

where subtract elements removed (in example "1" , "5").

tip: adding, can use:

// elements add var add = ["4", "5"]; // copy of current selected elements var values = multi.value().slice(); // merge withe elements add var merge = $.merge(values, add); // clean filtering multi.datasource.filter({}); // remove duplicates , set them multi.value($.unique(merge)); 

running example in here : http://jsfiddle.net/onabai/9wfga/


Comments