Populate a column as a result of performing math on two columns in a jqGrid.
Posted
by HacksawOnRye
on Stack Overflow
See other posts from Stack Overflow
or by HacksawOnRye
Published on 2010-04-01T14:10:41Z
Indexed on
2010/04/01
14:13 UTC
Read the original article
Hit count: 265
jqgrid
Background: Our company selected a workflow tool that has some "interersting" UI restrictions. jqGrid has been identified as one of best ways to overcome these restrictions. Consequently, the answers to this question need to be restricted to functionlity available within the jqGrid space. It pains me to pose this question and I know you will tempted to go down a million other paths - most that we have already traveled before. :(
Question: Can jqGrid populate a column as a result of performing math on two other columns. The source of those two columns is in our control so we can "guarantee" that numeric data will be returned. Also, the result is something that we simplay want to display on demand but not store yet. On the example below, is there a function that allow the 'total' column to be populated from the following calculation: 'amount' * 'tax'
Example jqGrid javascript:
jQuery("#list3").jqGrid({
url:'server.php?q=2',
datatype: "json",
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{name:'id',index:'id', width:60, sorttype:"int"},
{name:'invdate',index:'invdate', width:90, sorttype:"date"},
{name:'name',index:'name', width:100},
{name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
{name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},
{name:'total',index:'total', width:80,align:"right",sorttype:"float"},
{name:'note',index:'note', width:150, sortable:false}
],
rowNum:20,
rowList:[10,20,30],
pager: '#pager3',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
loadonce: true,
caption: "Load Once Example"
});
© Stack Overflow or respective owner