I have two issues here with my jqgrid table, first, it does not do sorting in ascending or descending order when you click on the column headers.
The problem I am having is I want to multiply Num1 and Num2 and show the output in the virtual Result column, How do i mutilpy the Num1 and Num2 and show the output in virtual column
i was using this example How do I make a non database column in jqGrid?
here is my code. my Result column doesnt show any of the result of Num1 x Num2
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.2/themes/redmond/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.4.5/css/ui.jqgrid.css" />
<style type="text/css">
html, body { font-size: 75%; }
</style>
<script type="text/ecmascript" src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.4.5/js/i18n/grid.locale-en.js"></script>
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.4.5/js/jquery.jqGrid.src.js"></script>
<title>Jqgrid data </title>
</head>
<body>
<div style="margin-left:20px">
<table id="nplGrid"></table>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#nplGrid").jqGrid({
url: 'json/data-bcp2.json',
datatype: "json",
colModel: [
{ label: 'Id', name: 'Id', width: 145 },
{ label: 'Symbol', name: 'Symbol', width: 90 },
{ label: 'Quantity', name: 'Quantity', width: 100, align: "right" },
/*{ label: 'Value1',
name: 'Value1',
width: 80,
sorttype: 'number',
formatter: 'number',
align: 'right'
}, */
{ label: 'Price', name: 'Price', width: 180, sorttype: 'number' , align: "right",formatter: 'currency', formatoptions: { prefix: " $", suffix: " "}},
{ label: 'Value', name: 'Value', width: 180, sorttype: 'number', align: "right",formatter: 'currency', formatoptions: { prefix: " $", suffix: " "} },
{ label: 'Pledged', name: 'Pledged', width: 80, sorttype: 'integer' } ,
{ label: 'Num2', name: 'Num2', width: 80, formatter:'currency' },
{ label: 'Result', name: 'Result', width: 80,formatter:'currency',
formatter:function(cellvalue, options, rowObject) {
var amount = parseInt(rowObject.Num1,10),
tax = parseInt(rowObject.Num12,10);
return $.fmatter.util.NumberFormat(amount*tax,$.jgrid.formatter.currency);
}
}
],
gridview: true,
rownumbers: true,
sortname: "invdate",
viewrecords: true,
sortorder: "desc",
caption: "Just simple local grid",
height: "100%",
footerrow: true,
loadComplete: function () {
var $self = $(this),
sum = $self.jqGrid("getCol", "Price", false, "sum");
$self.jqGrid("footerData", "set", {invdate: "Total:", Price: sum});
sum1 = $self.jqGrid("getCol", "Value", false, "sum");
$self.jqGrid("footerData", "set", {invdate: "Total:", Value: sum1});
}
});
});
</script>
</body>
</html>
JSON DATA BELOW:
{
"rows":[
{
"Id":"C14999",
"Symbol":"AA",
"Quantity":"10000000 ",
"Price":"2500000",
"Value":"2500000",
"Pledged":"Y",
"Num1":"4",
"Num2":"20"
},
{
"Id":"C14999",
"Symbol":"IRTX",
"Quantity":"253432250",
"Price":"3382000",
"Value":"857107.87",
"Pledged":"Y",
"Num1":"12",
"Num2":"31"
},
{
"Id":"C14999",
"Symbol":"MMM",
"Quantity":"143440000",
"Price":"100000",
"Value":"1434400",
"Pledged":"Y",
"Num1":"22",
"Num2":"20"
},
{
"Id":"C14999",
"Symbol":"FMCX",
"Quantity":"285657660",
"Price":"187125",
"Value":"62476901 ",
"Pledged":"N",
"Num1":"232",
"Num2":"20"
},
{
"Id":"C14999",
"Symbol":"CEB",
"Quantity":"1228000000",
"Price":"949000",
"Value":"116537200 ",
"Pledged":"Y",
"Num1":"2",
"Num2":"10"
},
{
"Id":"C23456",
"Symbol":"VETF",
"Quantity":"13984000000",
"Price":"256000",
"Value":"357990400",
"Pledged":"Y",
"Num1":"14",
"Num2":"20"
}
]
}