Saving row data with AngularJS ui-grid $scope.saveRow

后端 未结 3 2245
不思量自难忘°
不思量自难忘° 2021-02-09 22:12

I\'m working on a small frontend application which will show various product shipping data in a ui-grid.

I have the following code:

HTML:

3条回答
  •  梦如初夏
    2021-02-09 23:00

    You would normally do the promise/api call in a separate repository, but basically the code you are looking for is something like this:

     $scope.saveRow = function( rowEntity ) {
    
        var promise = $scope.someRepositoryFunction(rowEntity);
        $scope.gridApi.rowEdit.setSavePromise($scope.gridApi.grid, rowEntity, promise);
    
        // fake a delay of 3 seconds whilst the save occurs, return error if gender is "male"
        //$interval( function() {
        //    if (rowEntity.firstName === 'male' ){
        //        promise.reject();
        //    } else {
        //        promise.resolve();
        //    }
        //}, 3000, 1);
    };
    
    $scope.someRepositoryFunction = function(row) {
        return $http.put('/Home/UpdateRow',row);
    }
    

提交回复
热议问题