1
votes

I have a ui-grid in my page. I am allowing row edit, few cells in each row are editable. I have a save button and on click of that button I am getting all the dirty rows by $scope.grid1Api.rowEdit.getDirtyRows(); I am taking these dirty row values to the server by $http post request. Once the request is served successfully Again I am retrieving the fresh data from DB and setting it to the grid like $scope.mygrid.data = recentData; Now the grid shows the recent data. If i try to get the dirty rows now, it should not return any rows. But it returns the old edited rows

If any ideas, please share it.

1
AngularJs' 2-way data binding? Shouldn't you try to reset the ng-models you used in the form if a 200 response is returned from the HTTP request? - manu29.d
@manu29.d Yes. It is two way binding as per my understandings. Please let me know what you mean by resetting ng-models. As i am new i am struggling to find a way to reset the state of row entities to clean state. - Priya Darsini
I think you should look at official documentation of ng-submit. See what they're doing after the text is pushed to the array. - manu29.d

1 Answers

1
votes

After successful http post, you can clear the array of dirty rows:

scope.gridRows = scope.gridApi.rowEdit.getDirtyRows(); var dataRows = scope.gridRows.map(function (gridRow) { return gridRow.entity; }); scope.gridApi.rowEdit.setRowsClean(dataRows);