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

Here 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?

Thanks

4

1 回答 1

2

用于复选框的模板函数在您的“ checkTemplate”函数不可见的上下文中调用。全局定义:

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

在这里检查:http: //jsfiddle.net/OnaBai/K6cbc/5/

于 2014-05-28T14:31:02.797 回答