【问题标题】:kendoUI MVVM - TreeView with checkbox templatekendoUI MVVM - 带有复选框模板的 TreeView
【发布时间】:2014-05-28 13:02:02
【问题描述】:

我需要将 KendoUI TreeView 与 MVVM(声明式)绑定一起使用,并且我需要根据模型中的字段仅显示某些节点​​的复选框。

为此,我想使用checkbox template

但是,无论我做什么,我似乎都无法让它发挥作用

Here 是通过 MVVM 绑定树视图但没有复选框模板的小提琴

我想要的是使用函数 checkTemplate 作为复选框模板,通过如下定义树视图

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

但是,它不起作用。 有谁知道出了什么问题?

谢谢

【问题讨论】:

    标签: checkbox kendo-ui kendo-treeview kendo-mvvm kendo-template


    【解决方案1】:

    用于复选框的模板函数在“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/

    【讨论】:

    • 谢谢。实际上造成差异的是传递给模板的参数,我错过了。
    猜你喜欢
    • 1970-01-01
    • 2019-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-23
    • 1970-01-01
    • 2023-03-29
    相关资源
    最近更新 更多