I am attempting to do some basic things with the multiselect control. In this scenario, I need to precheck some items from session data and then whenever the selected items are changed I need to rewrite that session data to reflect the new selections.
The following is an example of my code, I bolded the relevant areas that seem to be giving me trouble:
<ejs-multiselect id="businessUnitsGlobal" dataSource="@Model.BusinessUnits" mode="CheckBox" placeholder="Business Units" created="businessUnitsGlobal_created" change="businessUnitsGlobal_change" width="150px" popupWidth="150px" cssClass="mb-1" showSelectAll="true" showDropDownIcon="true" filterBarPlaceholder="Search" popupHeight="350px">
<e-multiselect-fields text="Name" value="Id"></e-multiselect-fields>
</ejs-multiselect>
<script>
function businessUnitsGlobal_created(sender)
{
var url = "@Url.Action("GetBusinessUnits", "Session")";
ajaxPost(url, null, businessUnitsSession_loaded);
}
function businessUnitsSession_loaded(response)
{
if (response != null)
{
var businessUnitsGlobal = $("#businessUnitsGlobal")[0].ej2_instances[0];
businessUnitsGlobal.value = response.split(",");
}
}
function businessUnitsGlobal_change(args)
{
if (args.isInteracted)
{
var selectedBusinessUnits = args.value.join(",");
var url = "@Url.Action("SetBusinessUnits", "Session")";
var data = { businessUnits: selectedBusinessUnits };
ajaxPost(url, data, null);
}
}
</script>
So, as you can see, when the multiselect created event is fired, I grab the values that need to be preselected and set the value of the multiselect to that. This much works fine. Also, whenever I change the multiselects value, it accurately writes the new selection data back to the session. But the values that I select in that initial "created" event will not uncheck. I click on them and they just stay selected.
Any help on this is greatly appreciated.