Hello.
I try to update the item list in the multi checkbox filter popup by a separate datasource defined by a read action:
therefore I followed the instructions from the forum entry on
https://www.telerik.com/forums/refresh-multi-checkbox-filter-options-when-grid-is-filtered
Here a code snippet (MVC/Razor) :
columns
.Bound(column.Field)
.Filterable(f =>
{
// check if field shall use checkbox filter
if (Array.IndexOf(checkboxFilterFields, column.Field) >= 0)
//if (column.Field == "StateType" || column.Field == "PhaseShortText")
{
f.Multi(true); // activate multi checkbox filter
// setup checkbox filter list
f.DataSource(ds => ds.Read(r => r
.Action("ContractFilterListRead", "Contract", new
{
field = column.Field
}).Data("getFilterListReadParameters")
)
);
}
});
with a Javascript part:
<script>
$(document).ready(function () {
contractsGridController = new GridController('@(gridId)', '@(gridName)');
// bind click event of filter popup for checkbox filter list update
$(".k-grid-filter").click(function (event) {
//console.log("Gridfilter clicked");
var fmc = $(event.target).closest("th").data("kendoFilterMultiCheck");
if (fmc) {
// update filter popup content
fmc.checkSource.read();
fmc.container.empty();
fmc.refresh();
}
});
});
// getFilterReaderParameters gets client side filter and sort string
getFilterListReadParameters = function () {
console.log("getFilterReaderParameters()");
var filterAndSortString = contractsGridController.getGrid().dataItem($(".k-grid-content tr")[0]).PFilterAndSortStr; // get filter and sort string of first data item
console.log("Contract.Index: getFilterReaderParameters() filter and sort string: " + filterAndSortString);
return { "filterAndSortString": filterAndSortString };
};
</script>
This works like a charm if I use the grid filter mode "GridFilterMode.Menu".
If I switch to "GridFilterMode.Row" and add a Column Menu that contains the checkbox filter menu,
and changing the $(".k-grid-filter").click(function (event) part to $(".k-header-column-menu").click(function (event)
it doesn't work any more since the corresponding "th" element seems not having a kendoFilterMultiCheck object.
How can I access that kendoFilterMultiCheck of the Column Menu to update the item list?
BR, Matthias
I try to update the item list in the multi checkbox filter popup by a separate datasource defined by a read action:
therefore I followed the instructions from the forum entry on
https://www.telerik.com/forums/refresh-multi-checkbox-filter-options-when-grid-is-filtered
Here a code snippet (MVC/Razor) :
columns
.Bound(column.Field)
.Filterable(f =>
{
// check if field shall use checkbox filter
if (Array.IndexOf(checkboxFilterFields, column.Field) >= 0)
//if (column.Field == "StateType" || column.Field == "PhaseShortText")
{
f.Multi(true); // activate multi checkbox filter
// setup checkbox filter list
f.DataSource(ds => ds.Read(r => r
.Action("ContractFilterListRead", "Contract", new
{
field = column.Field
}).Data("getFilterListReadParameters")
)
);
}
});
with a Javascript part:
<script>
$(document).ready(function () {
contractsGridController = new GridController('@(gridId)', '@(gridName)');
// bind click event of filter popup for checkbox filter list update
$(".k-grid-filter").click(function (event) {
//console.log("Gridfilter clicked");
var fmc = $(event.target).closest("th").data("kendoFilterMultiCheck");
if (fmc) {
// update filter popup content
fmc.checkSource.read();
fmc.container.empty();
fmc.refresh();
}
});
});
// getFilterReaderParameters gets client side filter and sort string
getFilterListReadParameters = function () {
console.log("getFilterReaderParameters()");
var filterAndSortString = contractsGridController.getGrid().dataItem($(".k-grid-content tr")[0]).PFilterAndSortStr; // get filter and sort string of first data item
console.log("Contract.Index: getFilterReaderParameters() filter and sort string: " + filterAndSortString);
return { "filterAndSortString": filterAndSortString };
};
</script>
This works like a charm if I use the grid filter mode "GridFilterMode.Menu".
If I switch to "GridFilterMode.Row" and add a Column Menu that contains the checkbox filter menu,
and changing the $(".k-grid-filter").click(function (event) part to $(".k-header-column-menu").click(function (event)
it doesn't work any more since the corresponding "th" element seems not having a kendoFilterMultiCheck object.
How can I access that kendoFilterMultiCheck of the Column Menu to update the item list?
BR, Matthias