kendoUI MVVM - TreeView con plantilla de casilla de verificación

I need to use KendoUI TreeView with MVVM (declarative) binding, and I need to show checkboxes only for some nodes, based on a field in the model.

For this, I want to use checkbox template

However, whatever I do it seems I cannot make it work

Aquí is the fiddle with the treeview bound through MVVM but without checkbox template

What I want is to use the function checkTemplate as checkbox template, by defining the treeview as below

<div class="files"
    data-checkboxes="{checkChildren: true, template: checkTemplate }"
    data-bind="source: files"
    data-template= "ktmpl_Files">

However, it doesn't work. Does anyone has any idea what is wrong?

Muchas Gracias

preguntado el 28 de mayo de 14 a las 14:05

1 Respuestas

The template function used for checkboxes is invoked in a context where your "checkTemplate" function is not visible. Define it global:

<script type="text/javascript">
    function checkTemplate(e) {
        return "<input type='checkbox' style='display: " + (e.item.checkable ? "inline" : "none") + "'/>";

Compruébalo aquí:

contestado el 28 de mayo de 14 a las 15:05

Thanks. Actually what made the difference was the parameter passed to template, which I missed. - bzamfir

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.