kendoUI MVVM - TreeView con plantilla de casilla de verificación
Frecuentes
Visto 3,208 equipos
0
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-role="treeview"
data-text-field="name"
data-spritecssclass-field="type"
data-checkboxes="{checkChildren: true, template: checkTemplate }"
data-bind="source: files"
data-template= "ktmpl_Files">
</div>
However, it doesn't work. Does anyone has any idea what is wrong?
Muchas Gracias
1 Respuestas
2
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") + "'/>";
}
</script>
Compruébalo aquí: http://jsfiddle.net/OnaBai/K6cbc/5/
contestado el 28 de mayo de 14 a las 15:05
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas checkbox kendo-ui kendo-treeview kendo-mvvm kendo-template or haz tu propia pregunta.
Thanks. Actually what made the difference was the parameter passed to template, which I missed. - bzamfir