Save Data in Calculated/Virtual Column to Database
See code snippet below. Replace "orders" with your own table name please. You need to implement save_virtual_column.php to save data.
// post virtual column data to another page after
submit through another Ajax call
$afterSubmit =
<<<AFTERSUBMIT
function (event, status,
postData)
{
selRowId = $("#orders").jqGrid
('getGridParam', 'selrow');
virtual_data1 =
$("#orders").jqGrid("getCell", selRowId,
'total'); // data in virtual column
virtual_data2 =
$("#orders").jqGrid("getCell", selRowId,
'foo');
console.log('going to post virtual
column data ' + virtual_data1 + ', ' + virtual_data2 + ' to another
page through a separate AJAX call');
$.ajax({ url:
'save_virtual_column.php',
data: {v_data1:
virtual_data1, v_data2: virtual_data2}, // replace customerNumber
with your own field name
type:
'post',
success:
function(output) {
alert(output);
}
});
}
AFTERSUBMIT;
$dg->add_event("jqGridAddEditAfterSubmit",
$afterSubmit);
Read more about virtual column: http://phpgrid.com/example/virtual-column-aka-calculated-column/