AngularJS Kendo Treeview没有更新

时间:2014-03-23 06:57:02

标签: angularjs kendo-ui angular-kendo

感谢Angularjs + kendo-ui treeview的“像杰瑞德这样的话”的答案,我的树视图正常运行,一切都很好。直到 - 有人想根据复选框等更新/过滤树视图。我的问题是树没有更新以反映控制器中数据源的变化。

基于上面提到的答案中的jsfiddle,我创建了一个来显示我的问题。

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

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

选中该复选框不会影响树。 我是AngularJS和angular-kendo的新手,我想知道这种更新是否应该起作用。我可能会以错误的方式走这条路。任何帮助/建议都非常感谢。

谢谢!

1 个答案:

答案 0 :(得分:4)

您可以显式创建数据源,然后使用其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);
    }
}

updated demo