选择的Kendo-Knockout TreeView未定义

时间:2016-10-19 14:15:54

标签: javascript knockout.js kendo-ui treeview

我试图删除所选项目,但它始终未定义。

视图模型:

     var inline = new kendo.data.HierarchicalDataSource({
        data: data.layers,
        schema: {
            model: {
                children: "layers"
            }
        }
    });
    console.log(inline.data().toJSON())
    var viewModel = {
        treeViewDataSource: ko.observable(inline),
        onSelect: function(e) {
            console.log(viewModel.isSelected())
            e.preventDefault();
            $(that).trigger("treewasclicked", {
                data: $('#avaliableLayersul').data('kendoTreeView').dataItem(e.node)
            });

        },
        isSelected: ko.observable()
    };

还有View.Also我创建上下文(treeLayersVMVV是主模型的类,包括treeView模型)

<div id='avaliableLayers' data-bind="with: treeLayersVMVV">
        <ul id='avaliableLayersul' data-bind="kendoTreeView: {dataSource:treeViewDataSource,dataValueField:'options.id', dataTextField:'options.displayName',selectable: true , selected: isSelected , select: onSelect, checkboxes: {checkChildren: true}  }"></ul>
</div>

所以,首先,当我点击元素时,它不会变成橙色。元素只有光泽边框。正如我所知,这意味着未选择元素,但在DOM树中,单击元素处于活动状态。 怎么解决?谷歌并没有表现出来......

1 个答案:

答案 0 :(得分:0)

抱歉,

onSelect:e.preventDefault(); ... 但是,选择是未定义的