Correctly clearing the whole AngularJS ui-grid diagram

I am calling these codes at the beginning of my $ scope.generateReport function, hoping that it clears the data that is currently displayed in the grid when I click the button. Unfortunately this doesn't clear it.

I thought that by setting it with undefined values ​​the ui-grid would automatically update itself, clearing the entire grid.

$scope.generateReport = function() {

    $scope.gridOptions = {};
    $scope.gridOptions.data = undefined;
    $scope.gridOptions.columnDefs = undefined;
    $scope.gridApi.grid.refresh();
    ........
}

// on my html template, I have a button that has an ng-click
// ng-click="generateReport()"

      

+3


source to share


1 answer


Here's a plunker with an example of one way to do it:

http://plnkr.co/edit/Q1anj7jyPHz3LAXoir4E?p=preview



  $scope.clear = function() {
    $scope.myData.length=0;
  }

      

+9


source







All Articles