or
So I'm working with the Kendo Grid in MVC and my customer needs a grid in which he can filter columns on certain sets of choices. And he needs to see which filters are currently active.
I'm using a grid with the row filtermode set and I'm setting the template on the filter (through the FilterableSettings.CellSettings.Template.HandlerName property of the GridBoundColumn). I'm showing a dropdown with the choices the customer can check. Basically what I want to accomplish is this but it doesn't work with the row filtermode set. I found this example and I'm using it with the template to show a dropdown in every column, except it has side-effects I don't want. The effects are:
Below shows the code I'm having so far for the filtertemplate:
function filterMenu(container) { debugger; // Determine which field this is and get the appropriate choices var currentColumnIndex = $(".k-filter-row").children().length - 1; var headers = $($(".k-grid-header").children()[0]).children(); var currentHeader = headers[currentColumnIndex]; var customField = currentHeader.getAttribute("data-customfield"); // Use for support in < IE 11, otherwise could have use .dataset.customfield var choices = specialFilterFields[customField]; var dropDown = container.element.kendoDropDownList({ dataTextField: "Choice", dataValueField: "Choice", template: '<li unselectable="off" class="k-item nowrap check-item">' + '<input type="checkbox" name="#= Choice #" value="#= Choice #" class="check-input" />' + '<span>#= Choice #</span>' + '</li>', placeholder: "Filter...", select: function(e) { e.preventDefault(); }, dataSource: choices, valuePrimitive: false }).data("kendoDropDownList"); dropDown.list.find(".check-input,.check-item").bind("click", function (e) { var $item = $(this); var $input; if ($item.hasClass("check-item")) { $input = $item.find("input"); $input.prop("checked", !$input.is(":checked")); } else { $input = $item; } // Update the style of the checkboxes $.uniform.update($input); // Update the text of the dropdown updateDropDown(dropDown); e.stopImmediatePropagation(); }); updateDropDown(dropDown); } function updateDropDown(dropdown) { var items = []; dropdown.list.find(".check-input").each(function () { var $input = $(this); if ($input.val() != "" && $input.is(':checked')) items.push($input.val()); }); dropdown.text(items.toString()); }