Persist expanded/selected rows
Hi
How to persist expanded rows and selected rows after server data sync
Thanks
Hi, so is there a solution? thanks
Hi
Seems there is no official solution for that. I did manage to achieve that through 'onRegisterApi' ui grid event.
Note: This solution might be ugly but, worked for me :). You can try this until found the better solution.
onRegisterApi: function( gridApi ) { $scope.gridApi = gridApi;
$scope.gridApi.core.registerRowsProcessor(function(rows, columns) {
rows.forEach(function(row) {
if ($scope.grid_demo.expandedRows[row.entity.unique_key] != null) {
if (row.treeNode == null) row.treeNode = {};
row.treeNode.state = $scope.grid_demo.expandedRows[row.entity.unique_key].state;
}
});
// $scope.gridApi.saveState.restore($scope, $scope.grid_demo.state);
$(".grid_html_selector .ui-grid-viewport:eq(0)").scrollTop($scope.grid_demo.uiscrollTop);
return rows;
}, 399);
$scope.gridApi.treeBase.on.rowExpanded($scope, function(row) {
$scope.grid_demo.expandedRows[row.entity.unique_key] = { state: 'expanded' };
});
$scope.gridApi.treeBase.on.rowCollapsed($scope, function(row) {
$scope.grid_demo.expandedRows[row.entity.unique_key] = { state: 'collapsed' };
});
}
@jawaharlalt , thanks for the reply and sample code! I was thinking about similar solution, and seen few of them in stackoverflow. It's a pity there's no property to persist row's state in grid-ui...
Good luck!