Search code examples
kendo-uikendo-treelist

Kendo UI - Tree List on rebind lost exapnd and collapse functionality


I am using a Kendo UI in angular Js and binded my TreeList with Json, where I have set my parent and child properties as given.

schema: {
          model: {
           id: "Id",
           fields: {
             parentId: { field: "ParentId", nullable: true }
           }
          }
        }

And then I have a filter function on a button click which gets the required data from the json.

$scope.getFilteredData = function (id) {
                var filterData = _.filter($scope.bookSource, (item) => { return item.BookId == id; });

                if (filterData.length > 0) {
                    $scope.filteredDataSource = filterData;
                    $scope.ktlBookTreeList.setDataSource({
                        data: $scope.filteredDataSource
                    });
                }

            }

Although the data I get after the filter is correct , I dont have the expand collapse function any more. In one of the result set I got the parent record and two child records, even then the tree displayed it as separate rows, rather than with in the Expanded / collapsed rows.

Can you please guide me to understand what I am doing wrong here..


Solution

  • Probably you have to add the parent child model again, when you are resetting the data source.