I'm updating an application (based on version v2021.2.511) porting bits of code to a new application based on v2022.2.510). I'm trying to get a multi-select drop-down list with checkboxes working. The requirment is for the check boxes to be checked if an item in the list is selected, and unchecked if it is unselected.
The following styles were added:-
<style type="text/css">
@*.EditButton {
display:@ViewBag.EditButton;
}*@
.nopadding {
padding-left: 0 !important;
padding-right: 0 !important;
}
.k-multiselect:after {
content: "\25BC";
position: absolute;
top: 30%;
right: 10px;
font-size: 10px;
}
.k-multiselect-wrap.k-floatwrap li.k-button .k-icon.k-i-close
{
display: none !important;
}
}
</style>
<style scoped>
.k-widget.k-multiselect {
width: 300px;
vertical-align: middle;
display: inline-block;
}
</style>
The multiselect definition is:-
@(Html.Kendo().MultiSelect()
.Name("msSpecialty")
.DataValueField("Code")
.DataTextField("Description")
.Placeholder("All specialties...")
.ItemTemplate("<input type='checkbox' /> #=data.Description#")
.AutoClose(false)
.ClearButton(false)
.TagMode(TagMode.Multiple)
//.TagTemplate(" <span>#= Description #</span>")
.Events(e => e.Close("onSpecListChange").DataBound("specListDataBound").Change("chkFix"))
.DataSource(src => src.Read(rd => rd.Action("getOpenClockSpecDDL", "Validation")).ServerFiltering(false))
.HtmlAttributes(new { style = "width:300px;" })
)
And the javascript:-
var currentSpec = '-X-';
function onSpecListChange() {
var items = this.ul.find("li");
checkInputs(items);
//check if list has changed since last close, if so, fire change event (Avoids unnescessary requeries)
var multiselect = $("#msSpecialty").data("kendoMultiSelect");
var Svalue = multiselect.value().sort();
var SpecString = "";
if (Svalue != null & Svalue != '') {
for (i = 0; i < Svalue.length; i++) {
SpecString = SpecString + Svalue[i] + "|";
}
}
else {
SpecString = "-X-";
}
if (currentSpec != SpecString) {
onChange();
}
}
function checkInputs(elements) {
elements.each(function () {
var element = $(this);
var input = element.children("input");
input.prop("checked", element.hasClass("k-state-selected"));
});
}
function specListDataBound() {
var items = this.ul.find("li");
setTimeout(function () {
checkInputs(items);
});
}
function chkFix() {
var items = this.ul.find("li");
setTimeout(function () {
checkInputs(items);
});
}
function onChange()
{
}
I assume the styles have changed between the versions, because this code is not working. The checkboxes aren't being checked on selection, the list doesn't close when clicked away from, and the closed multiselect isn't displaying properly. How can I get it working as it was please?