我有 jqgrid 列交易 id、借方、贷方和余额。借方和贷方是从数据库中填充的,余额是通过计算贷方 - 借方的差异来设置的。编辑在editform中完成。有一次,用户更改了借方或贷方的值之一,我需要在网格的选定行中更新余额列。
任何帮助是极大的赞赏。
$myGrid.jqGrid({
url: myURL + '?method=GetTranactions',
postData: {
prID: function() { return getProv(); },
mn: function() { return $("#month option:selected").val(); },
yr: function() { return $("#year option:selected").val(); }
},
datatype: 'json',
mtype: 'POST',
colNames:['Trx ID','Debit','Credit','Balance',],
colModel :[
{name:'accttrx_id',index:'accttrx_id', width:75, sorttype:"int", editable:true},
{name:'debit',index:'debit',
width:70,
align:"right",
formatter:'number',
sorttype:"number",
editable:true,
edittype:"text",
editoptions:{
size:20,
defaultValue:'0',
dataEvents: [
{
type: 'change',
fn: function(e) {
var db = $(e.target).val();
var cr = $('#credit').val();
bal = cr - db; // got the balance
alert(bal); // how to update balance column for current row?
}
}
]
},
editrules:{required:true},
formoptions:{elmprefix:"(*)"}
},
{name:'balance',index:'balance',
width:70,
align:"right",
formatter:'number',
sorttype:"number",
editable:false},....
..................................................... .....................
$myGrid.navGrid('#pager', {
search:false,
edit:true,edittitle:"Edit Transation",
add:true,addtitle:"Add Transaction",
refresh:true,
del:true,deltitle:"Delete Transaction"
},
{
beforeShowForm:
function(form) {
$('#tr_accttrx_id', form).hide();
},
afterSubmit:
..... update balance after submit?