2

感谢Angularjs + kendo-ui treeview的“Words Like Jared”的回答的“Words Like Jared”的回答,我的 treeview 工作正常,一切都很好。直到 - 有人想根据复选框等更新/过滤树视图。我的问题是树没有更新以反映控制器中数据源的更改。

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

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

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

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

谢谢!

4

1 回答 1

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);
    }
}

更新的演示

于 2014-03-23T16:40:23.377 回答