I'm trying to use the row saving feature in combination with the expandable grid. The goal is to be able to save sub-grid rows, independently of the parent row.
$scope.gridOptions = {
expandableRowTemplate: 'components/grid/orderLineTemplate.html',
expandableRowHeight: 150,
expandableRowScope: {
subGridVariable: 'subGridScopeVariable'
},
columnDefs: [
{field: '_id'},
{field: 'number'}
]
};
$http.get(ORDER_API)
.success(function (data) {
for (var i = 0; i < data.length; i++) {
var rowScope = data[i];
rowScope.subGridOptions = {
appScopeProvider: $scope,
columnDefs: [
{field: 'amount'},
{field: 'packageAmount'},
{field: 'carrierAmount'}
],
data: rowScope.orderLines,
saveRow : $scope.saveRow
}
}
$scope.gridOptions.data = data;
});
$scope.gridOptions.onRegisterApi = function (gridApi) {
$scope.gridApi = gridApi;
gridApi.rowEdit.on.saveRow($scope, $scope.saveRow);
};
$scope.saveRow = function (order) {
var promise = $q.defer();
$scope.gridApi.rowEdit.setSavePromise(order, promise.promise);
if(order.number) {
$http.put(ORDER_API + '/' + order._id, order).success(function () {
promise.resolve();
}).error(function () {
promise.reject();
});
}
}
});
The saveRow function is called correctly when I edit a field in the parent row. When I edit a field in the sub-row, the following message appears in the console;
'A promise was not returned when saveRow event was raised, either nobody is listening to event, or event handler did not return a promise'
SaveRow is never called for the expanded sub-row.