Best way to refesh the angular ui-grid data. State refresh or feed new data to $scope.gridOptions.data?

1.4k views Asked by At

I have an Angular UI grid in my page. When the user double clicks one row, it shows a modal with the row data which the user can update.

Post successful update, i need to show the latest data in UI grid. To accomplish this, i have two options. They are,

  1. Post successful bankend call, i need to reload my current state using $state.go($state.current, {} ,{reload: true}). Which will fetch the grid data to load the page.

  2. Get the full list of updated data as the return of successful updation AJAX and , feed the data to the grid, ie $scope.gridOptions.data = latestData;

Please suggest the best approach.

1

There are 1 answers

1
huan feng On BEST ANSWER

Option #1 is definitely not an acceptable solution.

Option #2 is acceptable, you can refresh the gridOptions.data if necessary.

If you want a better performance, you do not need to get the full list, you can directly update the record once your post API is done. The pre-condition is you do not depend on any back-end data.