AngularJS剑道树视图不更新 [英] AngularJS Kendo Treeview not updating

查看:254
本文介绍了AngularJS剑道树视图不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于从言贾里德一样的回答在 Angularjs +剑道的UI树视图 ,我得到了我的TreeView工作,一切都很好。除非 - 有人想更新/筛选基于复选框之类的树视图。我的问题是树的不更新,以反映在控制器中所做的数据源的变化。

Thanks to the answer from "Words Like Jared" at Angularjs + kendo-ui treeview, I got my treeview working and everything was fine. Until - someone wanted to update/filter the treeview based on checkboxes and the like. My problem is that the tree does not update to reflect the change in the datasource made in the controller.

根据在上述答案的jsfiddle,我创建了一个显示我的问题。

Based on the jsfiddle in the answer mentioned above, I have created one to show my problem.

http://jsfiddle.net/rajeshmathew/LwDs5/

if ($scope.showLimitedRecords) {                    
$scope.thingsOptions = {dataSource: $scope.things2}                    
} else {
$scope.thingsOptions = { dataSource: $scope.things1 };                                        
}

检查复选框不影响树。
我是一个新手,AngularJS和角度,剑道,如果这种更新的甚至应该工作,我想知道。我可能会在这个错误的方式走了。任何帮助/建议得多AP preciated。

Checking the checkbox does not affect the tree. I am a newbie to AngularJS and angular-kendo, and I am wondering if this kind of an update is even supposed to work. I might be going at this the wrong way. Any help/suggestions are much appreciated.

谢谢!

推荐答案

您可以明确创建数据源,然后使用其API设置数据:

You could create the data source explicitly and then set the data using its API:

$scope.thingsOptions = {
    dataSource: new kendo.data.HierarchicalDataSource({
        data: $scope.things1
    })
}
$scope.toggleFlag = function () {
    if ($scope.showLimitedRecords) {
        $scope.thingsOptions.dataSource.data($scope.things2);
    } else {
        $scope.thingsOptions.dataSource.data($scope.things1);
    }
}

更新演示

这篇关于AngularJS剑道树视图不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆