AngularJS Kendo Treeview not updating

自作多情 提交于 2019-12-10 23:56:53

问题


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.

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

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.

Thanks!


回答1:


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

(updated demo)



来源:https://stackoverflow.com/questions/22587975/angularjs-kendo-treeview-not-updating

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!