Clear selected value(s) for Kendo multi select
Asked Answered
S

3

12

I have Kendo multiSelect control which is working perfectly fine. However I am facing issue to reset its selected value. The following is what I have tried so far :

$("#Department option:selected").removeAttr("selected");  

And

var departmentMultiselect = $('#Department').data("kendoMultiSelect");
var subtract = $('#department').val();
                var values = departmentmultiselect.value().slice();
                values = $.grep(values, function (a) {
                 return $.inarray(a, subtract) == -1;
                });
                departmentmultiselect.datasource.filter({});
                departmentmultiselect.value(values);  

In the second code, control bypasses the following code

values = $.grep(values, function (a) {
                     return $.inarray(a, subtract) == -1;
                    });  

How can I reset this control?

Shue answered 7/11, 2013 at 12:15 Comment(2)
Shouldn't $.grep filter function have two arguments (viz. the current array item and its index), these are mandatory as doc says.Sexuality
What do you mean by reset... unselect any values?Jardena
M
39

To unselect all values in kendo multiselect:

var multiSelect = $('#Department').data("kendoMultiSelect");
multiSelect.value([]);
Milk answered 11/3, 2014 at 7:18 Comment(1)
Thanks. This works perfectly. You could trim it down more and scrap the var. $('#Department').data("kendoMultiSelect").value([]);Storytelling
P
1

I had this same question, but wanted to remove only one value from the multiselect rather than everything. This is what I came up with:

var multiselect = $('#multiSelectId').data("kendoMultiSelect");
var values = multiselect.value().slice();

// optionId is the value I want to remove
var index = $.inArray(optionId, values);
if (index > -1) {
    values.splice(index, 1);
}

multiselect.dataSource.filter({});
multiselect.value(values);
Parrish answered 20/5, 2015 at 20:1 Comment(0)
E
0

Set's the multiselect to your Placeholder value

var multiselect = $("#ICD10CodeIds").data("kendoMultiSelect");
        multiselect.value(0);
Earthlight answered 18/1, 2021 at 11:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.