Trouble editing Angular ui-grid row with external form

时间:2015-08-07 02:39:15

标签: angularjs angular-ui-grid

This has to be easier than I'm making it. I have a ui-grid (http://ui-grid.info) that I'm editing with an external form via double-clicking the row. It works, but the way I'm doing it causes the edited row to go blank after clicking save, but the record IS updated in the database (via $resource). It even updates the cell as I type into the form, but still vanishes upon save.

Relevant Code:

$scope.gridOptions = {
      ...
      rowTemplate: '<div ng-dblclick=\"grid.appScope.onDblClick(row)\" ...'
}

$scope.onDblClick = function (row) {
     $scope.selected = row;
     $('.editform').show();
};

// attached to click handler of save button
$scope.save = function(edited) { 
   edited.entity.$save(function() {
        // at this point, the data is saved but the grid row
        // goes blank
        //
        // I can hack around it with this, but it's not efficient:
        store.query(function(data) {
            $scope.gridOptions.data = data;
        });
   });
}

<button class="ui button" type="submit" ng-click="save(selected)">Save</button>

I must be overlooking something simple. What say ye?

1 个答案:

答案 0 :(得分:-1)

没关系,我明白了。我将表单直接绑定到行数据,然后单击“保存”显然清除了表单,该表单由于绑定而清除行数据。

我最终制作了行数据的副本并将表单绑定到该行。