I'm trying to implement saving of nested grids when the parent grid is saved. The parent row has an identity column that is generated by the db. This column is also a foreign key in the nested grid rows, so I need the value before saving the nested grid. At what point after calling commit() on the parent grid will the identity be populated in the parent row?
function saveChanges(){
//attempt to save editing cell.
if (grid.saveEditCell() === false) {
return false;
}
if (grid.isDirty() && grid.isValidChange({ focusInvalid: true }).valid) {
var changes = grid.getChanges({ format: 'byVal' });
// Save changes to db
$.ajax({
dataType: "json",
type: "POST",
async: false,
beforeSend: function (jqXHR, settings) {
grid.showLoading();
},
url: "SaveChanges",
data: { strChanges: JSON.stringify(changes) },
success: function (changes) {
grid.commit({ type: 'add', rows: changes.addList });
grid.commit({ type: 'update', rows: changes.updateList });
grid.commit({ type: 'delete', rows: changes.deleteList });
grid.history({ method: 'reset' });
},
complete: function () {
grid.hideLoading();
}
});
}
}