<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: jqGrid: How do I sum the values in columns and use result</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>dux on jqGrid: How do I sum the values in columns and use result</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21204</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21204</guid>
        	        	<description><![CDATA[<p><strong>Thank you, chillifire, great job</strong></p>
<p><strong>&#160;</strong></p>
]]></description>
        	        	<pubDate>Tue, 07 Dec 2010 16:53:02 +0200</pubDate>
        </item>
        <item>
        	<title>chillifire on jqGrid: How do I sum the values in columns and use result</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21161</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21161</guid>
        	        	<description><![CDATA[<p>OK, here is a project solution &#8211; works for me. May need some more REGEX magic for theNOT type operators, and you need to add a numerical comparison in parallel to the regex for lt, le, gt, and ge, plus an array comparison for in, ni. Maybe there is a better way of doing the filter comparison , so please if anyone else is interested, they can add to this solution. It will certainly work fine with a searchToolbar, with the standard bw operator and more common character based comparisons. It also takes care of case sensitivity using the "i" option of the RegEx object.</p>
</p>
<p>Any improvements welcome, although performance is good, testing on 10.000 records the sum builds as fast as the underlying grid &#8211; no decernable delays.</p>
</p>
<p>Here goes. Relevant parts in <strong><em>bold/italic</em></strong>:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit5113' value='Select Code' data-codeid='sfcode5113' /></p>
<div class='sfcode' id='sfcode5113'>
<p>jQuery(&#34;#listSales&#34;).jqGrid({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; url:&#39;../json/sales?horizon=1&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: &#34;json&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; height: 450,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; width: 980,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames:[&#39;ID&#39;, &#39;Sub-Account&#39;, &#39;Account&#39;, &#39;Partner&#39;, &#39;Admin&#39;, &#39;Transaction ID&#39;, &#39;Transaction date&#39;, &#39;Name&#39;, &#39;Email&#39;, &#39;Amount&#39;, &#39;Cur&#39;, &#39;Vocher&#39;, &#39;Received&#39;, &#39;Mobile&#39;, &#39;Package Id&#39;, &#39;Package Name&#39;, &#39;Expiration&#39;, &#39;User&#39;, &#39;User Mac&#39;, &#39;NasID&#39;, &#39;Router MAC&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel:[<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;rowID&#39;,hidden: true},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;account&#39;,index:&#39;account&#39;, width:60},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;affiliate&#39;,index:&#39;affiliate&#39;, width:60},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;partner&#39;,hidden: true},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;admin&#39;,hidden: true},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;transid&#39;,index:&#39;transid&#39;, width:110},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;transdate&#39;,index:&#39;transdate&#39;, width:90},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;name&#39;,index:&#39;name&#39;, width:100},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;email&#39;,index:&#39;email&#39;, width:150},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;amountpaid&#39;,index:&#39;amountpaid&#39;, width:40, sorttype:&#39;int&#39;, formatter: &#39;number&#39;},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;currency&#39;,index:&#39;currency&#39;, width:25},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;voucher&#39;,index:&#39;voucher&#39;, width:10,formatter:&#39;checkbox&#39;},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;youoweus&#39;,index:&#39;youoweus&#39;, width:10,formatter:&#39;checkbox&#39;},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;mobile&#39;,hidden: true},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;timeid&#39;,hidden: true},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;package&#39;,hidden: true},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;expiration&#39;,hidden: true},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;userid&#39;,hidden: true},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;mac&#39;,hidden: true},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;nasid&#39;,hidden: true},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;routermac&#39;,hidden: true},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; ],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowNum:20,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; loadonce:true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; scroll: 1,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; mtype: &#34;GET&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; rownumbers: true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; rownumWidth: 30,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; gridview: true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; pager: &#39;#pager&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortname: &#39;transdate&#39;,<strong><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;<em> ignoreCase: true,</em></strong><br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; loadui: &#34;block&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; viewrecords: true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortorder: &#34;desc&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; caption: &#34;&#60;?= $this-&#62;contentHeader ?&#62;&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; footerrow : true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; userDataOnFooter : true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; altRows : true,<br /><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <em>loadComplete: function() {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var footerData = new sumAmountPaid();<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var footerRow = jQuery(&#34;#listSales&#34;).footerData(&#39;set&#39;,footerData, false);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</em></strong><br />&#160;&#160;&#160; });<br />&#160;&#160;<strong>&#160; <em>jQuery(&#34;#listSales&#34;).jqGrid(&#39;filterToolbar&#39;,{stringResult:true,searchOnEnter:false,defaultSearch:&#34;cn&#34;});</em></strong></p>
</p>
<p><em><strong>function sumAmountPaid() {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; // read grid data<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var thedata = jQuery(&#34;#listSales&#34;).getGridParam(&#39;data&#39;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; // read filters<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var postData = jQuery(&#34;#listSales&#34;).getPostData();<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; // convert POST filters into usuable REGEX format &#8211; but only if there is a search<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(postData._search) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var filterObj = jQuery.parseJSON(postData.filters);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // extract group Operator<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var groupOp = filterObj.groupOp;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //construct REGEX filter array<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var filterArray = new Array();<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery.each(filterObj.rules,function(theKey,theValue) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // the &#34;i&#34; is required for the jqGrid setting ignoreCase: true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // remove it for and ignoreCase: false type jqGrids<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; switch (theValue.op) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case &#39;cn&#39;:<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; filterArray[theValue.field] = new RegExp(theValue.data, &#34;i&#34;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case &#39;bw&#39;:<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; filterArray[theValue.field] = new RegExp(&#39;^&#39; + theValue.data, &#34;i&#34;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case &#39;ew&#39;:<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; filterArray[theValue.field] = new RegExp(theValue.data + &#39;$&#39;, &#34;i&#34;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case &#39;eq&#39;:<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; filterArray[theValue.field] = new RegExp(&#39;^&#39; + theValue.data + &#39;$&#39;, &#34;i&#34;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case &#39;nc&#39;:<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; filterArray[theValue.field] = new RegExp(&#39;^(?:(?!&#39; + theValue.data +&#39;).)+$&#39;, &#34;i&#34;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case &#39;bn&#39;:<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; filterArray[theValue.field] = new RegExp(&#39;^(?:(?!&#39; + theValue.data +&#39;).)$&#39;, &#34;i&#34;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case &#39;en&#39;:<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; filterArray[theValue.field] = new RegExp(&#39;(?:(?!&#39; + theValue.data +&#39;).)$&#39;, &#34;i&#34;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case &#39;ne&#39;:<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; filterArray[theValue.field] = new RegExp(&#39;^(?:(?!&#39; + theValue.data +&#39;).)$&#39;, &#34;i&#34;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; })<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; // initialise values<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var thesum = 0;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var thecurrency=&#34;n/a&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; // loop over grid data<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; for(var i=0;i &#60; thedata.length; i++) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // add vlaues if there is no search or if the search criteria meet the data<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (!(postData._search) &#124;&#124; matchFilter(thedata[i],filterArray,groupOp)) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //make sure data is value and not string &#8211; then add<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; thesum += parseFloat(thedata[i].amountpaid);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // the values I add are currencies, only add if it is the same currency, otherwise stop adding &#8211; simialr applies for anything with a ubit of measure (UOM)&#160; and if the constance of the UOM caanot be guranteed)<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (thecurrency == &#34;n/a&#34;) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; thecurrency = thedata[i].currency;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // give some standard values, if the UOM is not the same throughout<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (thecurrency != thedata[i].currency) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.name = &#39;Total:&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.amountpaid = &#39;n/a&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.currency = &#39;n/a&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.name = &#39;Total:&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.currency = thecurrency;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; // format and round the number<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(thesum == 0) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.amountpaid = &#39;0.00&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; this.amountpaid = roundNumber(thesum, 2);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; }</strong></em></p>
<p>&#160;&#160;&#160; function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return newnumber;<br />&#160;&#160;&#160; }<br />&#160;&#160;&#160; function matchFilter(data, filterArray, groupOp) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; var valid = true;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; // read filter array<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; for (var theKey in filterArray) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //compare data field with filter<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (data[theKey].search(filterArray[theKey]) != -1) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //if it is an OR, one match is enough<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(groupOp == &#34;OR&#34;) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return true;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; valid = true;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //if it is an AND, one fail is enough<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(groupOp == &#34;AND&#34;) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return false;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; valid = false;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return valid;<br />&#160;&#160;&#160; }</p>
</div>
]]></description>
        	        	<pubDate>Mon, 06 Dec 2010 00:15:29 +0200</pubDate>
        </item>
        <item>
        	<title>chillifire on jqGrid: How do I sum the values in columns and use result</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21127</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21127</guid>
        	        	<description><![CDATA[<p>Hi,</p>
</p>
<p>I don&#39;t think what you are trying to do is contrary to how jqGrid&#160;works&#160;at all - at least as of 3.7. Responses like #2 are referring to a world where everything was referred back to the server sorting, pagination, totals. As of 3.7 jqGrid introduced the loadonce option and now it is reasonable to expect that it can perform all the actions for which it previously needed server communication locally - using jquery and javascript. In fact sorting and filtering on local data already works.</p>
<p>And advice like &#39;you should go back to the server for everything&#39; are not very helpful. What if I did requested the total on a filtered set of rows, but the data on the server has already&#160;changed&#160;due to other user&#39;s activity. Then the totlas do not match my local dta naymore. Or I have to load all the data again, subverting the&#160;whole&#160;point of local data and &#39;loadonce&#39;.</p>
<p>The missing bit for total is that you cannot easily get to all the filtered data. you can get to all them loaded data, and the filtered data rows &#160;that is currently visible on the screen. As far as I can make out you cannot easily access the array of ALL filtered rows.</p>
<p>So what you have to do until the makers of jqGrid have provided this function in standard.</p>
<p>On a load complete event get all the data with .getGridParam(&#39;data&#39;), then get the filters with .getGridParam(&#39;postData&#39;), transcribe the filters into a RegEx and run them over all the data. If it fits save the record in a new array with filtered data, calculate your totals, push the totals into userData or directly into the footer with .footerData.</p>
<p>I am working on a custom&#160;solution&#160;for my specific requirements, buit am happy to post the code, once finished. In the meantime I hope the developers have mercy on us and provide this function in standard as requested here: /blog/?page_id=393/feature-request/totals-on-local-data-for-userdata/&#38;value=local%20data&#38;type=1&#38;include=1&#38;search=1&#38;ret=all</p>
]]></description>
        	        	<pubDate>Fri, 03 Dec 2010 22:12:34 +0200</pubDate>
        </item>
        <item>
        	<title>wakelt on jqGrid: How do I sum the values in columns and use result</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21116</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21116</guid>
        	        	<description><![CDATA[<p>Perhaps my desire to have the client perform the summation is due to my lack of jqgrid understanding...Your help is much</p>
<p>appreciated !! Please address the following jqgrid questions:</p>
</p>
<p>1) If I do a row edit within jqGird, a POST to the server occurs with the contents of the row and several other operators.&#160; Will jqGrid take the Server response (assume xml) and re-populate the row that was edited ??? If so, that would be great.</p>
</p>
<p>2) Is there a way to submit the entire form (all data rows) to the server ?? Some rows may have dependencie&#39;s on others ??</p>
</p>
<p>thanks again;</p>
<p>wk</p>
]]></description>
        	        	<pubDate>Fri, 03 Dec 2010 16:00:07 +0200</pubDate>
        </item>
        <item>
        	<title>wakelt on jqGrid: How do I sum the values in columns and use result</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21109</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21109</guid>
        	        	<description><![CDATA[<blockquote>
<p>waiting said:You should do this on server (php/asp..), sum and construct data, not at front side.</p>
</blockquote>
<hr />
<p>I realize that the summation can happen on the server side, but..</p>
</p>
<p>it seems that if the data is entered on the client side, there is no reason not to sum it on the client side before handing it to the server. This would allow the golfer to see his summed score, without having to go to the server then back to the client with the result. Is it not technically possible to do this with jquery/jqgrid ?? thnx,wk</p>
]]></description>
        	        	<pubDate>Fri, 03 Dec 2010 14:44:20 +0200</pubDate>
        </item>
        <item>
        	<title>waiting on jqGrid: How do I sum the values in columns and use result</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21100</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21100</guid>
        	        	<description><![CDATA[<p>You should do this on server (php/asp..), sum and construct data, not at front side.</p>
]]></description>
        	        	<pubDate>Fri, 03 Dec 2010 08:32:10 +0200</pubDate>
        </item>
        <item>
        	<title>wakelt on jqGrid: How do I sum the values in columns and use result</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21097</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-how-do-i-sum-the-values-in-columns-and-use-result#p21097</guid>
        	        	<description><![CDATA[<p>I am doing a project for school and have decided to include jqGrid into the learning experience. I am trying to instrument a golf score card. The card has a header row. It then has 4 other rows, one row for each player in the match. I have 9 columns that are used for per hole scores. I&#39;d like to sum these 9 columns and place the result in a 10th column. What&#39;s the best way to construct this 10th column ??</p>
<p>Also, how do I change the height of a row ??&#160;My header row text is getting cutoff at the bottom.</p>
</p>
<p>Lastly, how do I set the default value for each row w/o having to make a call to the server ??&#160;I&#39;d like to init the score columns to a certain value w/o making a call.</p>
</p>
<p>thanks in advance for your help;<br />Walter</p>
]]></description>
        	        	<pubDate>Fri, 03 Dec 2010 07:39:57 +0200</pubDate>
        </item>
</channel>
</rss>