在JqGrid for PHP中的行编辑时自动增加字段?
问题描述:
In JqSuite
for PHP, I am trying to auto-increment a field value everytime I submit a row edit.
My code is not working though!
grid.php excerpt:
$custom = <<<CUSTOM
var rowId;
var keys, oneditfunc, succesfunc, url, extraparam, errorfunc, afterrestorefunc;
function aftersavefunc(rowId, response) {
alert("aftersavefunc Fired!");
alert(rowId);
$("#grid").jqGrid('setCell', rowId, 'revision', '3');
}
jQuery("#grid").jqGrid('editRow', rowId, keys, oneditfunc,
succesfunc, url, extraparam, aftersavefunc, errorfunc, afterrestorefunc);
CUSTOM;
I don't even get the alert popup from alert("aftersavefunc Fired!");
Is anybody able to do this?
答
I found a solution to my question: I just needed to use:
$cid = jqGridUtils::GetParam('my_id');
$grid->setAfterCrudAction('edit', "UPDATE my_table SET revision = revision + 1 WHERE my_id=?",array($cid));