Hi,
I have implemented the filter multi check as described here:
http://demos.telerik.com/aspnet-mvc/grid/filter-multi-checkboxes
and I have persisted the grid using the methods described here:
http://demos.telerik.com/aspnet-mvc/grid/persist-state
For the checkboxes, I have a method server side which returns the filter checkboxes as Json.
Code Snippet:
@(Html.Kendo().Grid<DefectNotificationReportItemDto>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.MaterialCode).Width(140).Filterable(f => f.Multi(true).ItemTemplate("itemTemplate").Search(true).DataSource(source => source.Read(r => r.Action("GetMaterialCodes", "DefectNotificationReport", new { selectedSnapshotDate = Model.ToString("dd MMM yyyy") }))));
columns.Bound(p => p.MaterialDescription).Width(300).Filterable(f => f.Multi(true).ItemTemplate("itemTemplate").Search(true).DataSource(source => source.Read(r => r.Action("GetMaterialDescriptions", "DefectNotificationReport", new { selectedSnapshotDate = Model.ToString("dd MMM yyyy") }))));
columns.Bound(p => p.BatchNumber).Width(140).Filterable(f => f.Multi(true).ItemTemplate("itemTemplate").Search(true).DataSource(source => source.Read(r => r.Action("GetBatchNumbers", "DefectNotificationReport", new { selectedSnapshotDate = Model.ToString("dd MMM yyyy") }))));
}
function itemTemplate(e) {
if (e.field === "all") {
//handle the check-all checkbox template
return "<div><label><strong><input type='checkbox' />#= all#</strong></label></div>";
} else {
//handle the other checkboxes
return "<div class='kendo-custom-filter'><span><label><input type='checkbox' name='" + e.field + "' value='#=Value#'/><span>#= Text #</span></label></span></div>";
}
}
Everything works fine, until the state of the grid is reloaded. If I then click on a filter I get a JavaScript error:
VM12456:3 Uncaught ReferenceError: BatchNumber is not defined
at eval (eval at compile (kendo.all.js:194), <anonymous>:3:209)
at Object.render (kendo.all.js:175)
at Object.proxy [as render] (jquery-3.1.1.js:502)
at init.createCheckBoxes (kendo.all.js:37796)
at init.refresh (kendo.all.js:37762)
at init.options.forceUnique.checkChangeHandler (kendo.all.js:37614)
at init.trigger (kendo.all.js:124)
at init._process (kendo.all.js:6965)
at init.success (kendo.all.js:6710)
at success (kendo.all.js:6637)
I find all of your features are great in isolation but when combined this sort of things happens. Please can you tell me why this happens and how I can fix the issue?
Thanks