vendredi 30 octobre 2015

Kendo Grid Filter ItemTemplate with multiCheck get checkbox state

I have no Idea how to formulate this question better, but this is the scenario:

I'm working on a big webapp for a client that uses telerik kendo UI for the grid. One of the columns in the grid is set to filter and uses multiCheck. So far everything works well and I'm happy with the result.

Now for the kicker though: The checkboxes were styled (which means they are hidden and a surrounding container diplays the value) and work for the first time you use the filter, since none of the checkboxes are selected. Once I select some values and filter the grid, the filter menu is being redrawn and the selected checkboxes are being emptied.

What I need to do now is have a condition in the itemTemplate to set the class that shows the checkbox value.

My current itemTemplate looks like this:

function documentTypeItemTemplate(e) {
    var s = "<div class='checker'>";
    s += "<span tabindex='0' role='checkbox' aria-checked='false'>";
    s += "<input id='filter_" + e.field + "' type='checkbox' value='#=Value#' name='" + e.field + "' onchange='Wpl.SettingsContext.CheckboxChanged(this);' tabindex='-1' aria-hidden='true' />";
    s += "<label for='filter_" + e.field + "'>#=Text#</label></span></div>";
    return s;
}

but for a checked Checkbox I would need it to look like:

function documentTypeItemTemplate(e) {
    var s = "<div class='checker'>";
    s += "<span tabindex='0' class="checked" role='checkbox' aria-checked='true'>";
    s += "<input id='filter_" + e.field + "' type='checkbox' value='#=Value#' name='" + e.field + "' onchange='Wpl.SettingsContext.CheckboxChanged(this);' tabindex='-1' aria-hidden='true' />";
    s += "<label for='filter_" + e.field + "'>#=Text#</label></span></div>"";
    return s;
}

Does anyone have a clue if that's possible at all? I went through the whole Kendo UI Page twice and didn't get any information on itemTemplate apart from the basic definition of it.

Thanks for your help

Cheers H.2.O




Aucun commentaire:

Enregistrer un commentaire