<?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: Proper way to page jqGrid</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/proper-way-to-page-jqgrid</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/proper-way-to-page-jqgrid/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>popsovy on Proper way to page jqGrid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/proper-way-to-page-jqgrid#p27995</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/proper-way-to-page-jqgrid#p27995</guid>
        	        	<description><![CDATA[<p>I need to display a number of "dynamic" grids using jqGrid. By dynamic I mean that both definition and data of the grid are retrieved from a database. There are many grids on the page, so I am trying to minimize the number of server trips, and there is a lot of data, so server-side paging is a must.</p>
<p>My workflow is</p>
<ul>
<li>On initialization of each grid, retrieve grid      definition and first page of data in&#160;<em>one</em>&#160;server call.</li>
<li>If a user sorts/pages, then retrieve a page of data      from the server</li>
</ul>
<p>Because I want to retrieve the grid definition and first page of data in one call, I cannot use datatype: &#39;json&#39;, url: &#39;###&#39; approach; instead I do:</p>
</p>
<p>grid.jqGrid({</p>
<p>&#160;&#160;&#160; mtype: &#39;post&#39;,</p>
<p>&#160;&#160;&#160; &#8230;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</p>
<p>&#160;&#160;&#160; datatype: function (postdata) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (!init.data) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var request = {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; screenId: settings.screenId,</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; pageNumber: postdata.page,</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; pageSize: postdata.rows,</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortColumn: postdata.sidx,</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortDirection: postdata.sortd,</p>
<p>&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;date: settings.date</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; };</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; site.callWs("/MyService", request, function (pageResponse) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //WHAT TO CALL HERE TO SET A PAGE OF DATA?</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //WHAT TO CALL HERE TO SET A PAGE OF DATA?</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; init.data = null;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
<p>&#160;&#160;&#160; }</p>
<p>});</p>
<p>My data object (pageResponse or init.data) looks like this</p>
</p>
<p><a href="http://i.stack.imgur.com/6ngtu.png"><img src="http://i.stack.imgur.com/6ngtu.png" width="100"  class="sfimageleft spUserImage" alt="Data Page" /><img src="http://www.trirand.com/blog/wp-content/sp-resources/forum-themes/default/images/sp_Mouse.png" class="sfimageleft sfmouseleft" alt="Image Enlarger" /></a></p>
<p>I am not sure what method to call on jqGrid once a page of data is returned. I considered addJSONData, but it seems so inefficient to convert JSON back to string, then use EVAL(). Also, considered addRowData or setting the data property, but I am confused how to instruct jqGrid that I am doing server-side paging &#8212; if I set the data property to one page of records, what do I need to do to tell jqGrid that there is a total of 50 records and this is page 1 out of 10.</p>
<p>Thanks for your help</p></p>
]]></description>
        	        	<pubDate>Wed, 09 Jan 2013 17:42:11 +0200</pubDate>
        </item>
</channel>
</rss>