<?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: Client side page calculation</title>
	<link>http://www.trirand.com/blog/?page_id=393/feature-request/client-side-page-calculation</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/feature-request/client-side-page-calculation/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>gastaldi on Client side page calculation</title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/client-side-page-calculation#p19289</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/client-side-page-calculation#p19289</guid>
        	        	<description><![CDATA[<blockquote>
<p>Where did that "desc.rowNum" came from ?</p>
</blockquote>
]]></description>
        	        	<pubDate>Wed, 25 Aug 2010 00:24:43 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Client side page calculation</title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/client-side-page-calculation#p14986</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/client-side-page-calculation#p14986</guid>
        	        	<description><![CDATA[<p>Hello Mathias,</p>
<p>Good catch. Will be done.</p>
<p>Thanks</p>
<p>Best Regards</p>
]]></description>
        	        	<pubDate>Sat, 20 Feb 2010 11:23:45 +0200</pubDate>
        </item>
        <item>
        	<title>cylab on Client side page calculation</title>
        	<link>http://www.trirand.com/blog/?page_id=393/feature-request/client-side-page-calculation#p14962</link>
        	<category>Feature Request</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/feature-request/client-side-page-calculation#p14962</guid>
        	        	<description><![CDATA[<p>Hi there</p>
<p>I tried to load a SOLR json result in jqGrid, but unfortunately the SOLR result (I have no control of) does not contain page and total, so I needed a way to calculate the value from the "start" and "numFound" fields incorporated in the SOLR result.</p>
<p>To make this work, I needed to add</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit9855' value='Select Code' data-codeid='sfcode9855' /></p>
<div class='sfcode' id='sfcode9855'>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( typeof expr === &#39;function&#39;) return expr(obj);</div>
</p>
<p>in the getAccessor() function (around line 453 in the grid.base.js source). Now I can write</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit3061' value='Select Code' data-codeid='sfcode3061' /></p>
<div class='sfcode' id='sfcode3061'>
<p>&#160;&#160;&#160;&#160;&#160;&#160; jsonReader: {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; root: &#34;response.docs&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; records: &#34;response.numFound&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; total: function(data){ <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160; return Math.ceil( data.response.numFound /<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; data.response.docs.length )<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160; },</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; page: function(data){<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160; return Math.floor( data.response.start /<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; desc.rowNum )+1<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160; },</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; id: &#34;id&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; repeatitems: false<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</div>
<p>to calculate the needed values. Maybe this is useful to others here, so I thought to just post it.</p>
<p>The whole getAccessor definition in grid.base.js now looks like this:</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit7466' value='Select Code' data-codeid='sfcode7466' /></p>
<div class='sfcode' id='sfcode7466'>&#160;&#160; &#160;&#160;&#160;&#160; getAccessor = function(obj, expr) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;var ret,p,prm;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if( typeof expr === &#39;function&#39;) return expr(obj); // this line is new &#8211; nothing else<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;ret = obj[expr];<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if(ret===undefined) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if ( typeof expr === &#39;string&#39; ) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;prm = expr.split(&#39;.&#39;);<br />&#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;try {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if(prm.length) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;ret = obj;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;&#160; while (ret &#38;&#38; prm.length) {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;p = prm.shift();<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;ret = ret[p];<br />&#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; &#160;} catch (e) {}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;return ret;<br />&#160;&#160; &#160;&#160;&#160; &#160;}</div>
</p>
<p>Best regards</p>
<p>Mathias</p>
]]></description>
        	        	<pubDate>Fri, 19 Feb 2010 19:23:20 +0200</pubDate>
        </item>
</channel>
</rss>