Reputation: 523
Is there any way to completely empty a ui-grid (filters,data, column and all)?
I'm trying to empty the grid on button-click so that a new http request can be made and the result displayed using the same grid without reloading the page.
I tried $scope.gridOptions.length=0
but the data remains and on making an new request, the result gets appended to the previous result
Upvotes: 0
Views: 1013
Reputation: 1
$scope.gridOptions.data = [];
seems to work.. However it probably doesn't get rid of columns, which is what you wanted. In fact it clearly doesn't, this would be a normal thing to do if you wanted to clear the rows but keep the columns.
Upvotes: 0
Reputation: 32817
To empty a ui-grid data you will need to reinitialize via any array syntax.
$scope.gridOptions.data= [];
To clear all filters ,columns, you will need to later reinitialize the gridOptions itself via object literal syntax.
$scope.gridOptions= {};
Upvotes: 1
Reputation: 861
Changing the length of grid doesn't make any effect on data. Try this:
$scope.gridOptions.data = {};
Upvotes: 0