I have a Jqgrid with multiple row inline edit. I need to add edit rule for the grid.
I have two columns namely Requested Qty(value is already present) and Approved Qty (which I need to enter in Edit mode). In edit mode, entered value of approved qty should be less than/equal to Requested qty.
How can I get value of other column in edit rule ? How can I perform row validation to compare other column values?
In your save row
click function, you can validate one cell's value compared to another:
$("#yourSaveButtonID").click(function (event) {
// get the current row's ID
var rowID = $("#yourGridID").jqGrid('getGridParam', 'selrow');
// get the Approved Qty value
var cell_approvedQty = $("#yourGridID #" + rowID + "_approved_qty_column_name").val();
// get the Requested Qty value
var cell_requestedQty = $("#yourGridID #" + rowID + "_requested_qty_column_name").val();
// compare them
if (cell_approvedQty > cell_requestedQty) {
alert("Approved Qty must be less than or equal to Requested Qty");
event.preventDefault();
}
});
You will have to change _approved_qty_column_name
and _requested_qty_column_name
to your actual column names. Just remember to keep the leading _
- it is required for this selector.