I am using jqGrid 4.6.0 version for inline add/edit/delete feature. I want to validate the inline row information before submitting it to the server on save button click. For this i have written an ajax call under "beforeSaveRow" event. where i am returning true / false flag based on the output.
below is my code:
jQuery.extend(true, $.jgrid.inlineEdit, {
beforeSaveRow: function (options, rowid) {
var validateFlag = false;
var postData = {
ID: $("#new_row_ID").val(),
Name: $("#new_row_Name").val()
}
$.ajax({
type: "POST",
url: validateInlineRowData,
dataType: 'json',
data: {
postData
},
success: function (response) {
if (response.ID > 0) {
// display a popup with error message
validateFlag = false;
}
else {
// continue with editUrl by setting the flag to 'true'
validateFlag = true;
}
}
});
return validateFlag;
}
});
My issue is , even if I set the validateFlag flag to true in else part, the inline save action is not taking place. and if I set the default value of validateFlag to true then my ajax call to validate the row is not taking place.
please help me to solve this issue.