<?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: jqGridImport with json and server-side paging</title>
	<link>http://www.trirand.com/blog/?page_id=393/bugs/jqgridimport-with-json-and-server-side-paging</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/bugs/jqgridimport-with-json-and-server-side-paging/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>JulianC on jqGridImport with json and server-side paging</title>
        	<link>http://www.trirand.com/blog/?page_id=393/bugs/jqgridimport-with-json-and-server-side-paging#p20946</link>
        	<category>Bugs</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/bugs/jqgridimport-with-json-and-server-side-paging#p20946</guid>
        	        	<description><![CDATA[<p>Hi there,<br />Not sure if this is a bug, but I can&#39;t seem to get this working properly.&#160; We have a solution that is written in&#160;ASP.NET using MVC2 and jQuery.&#160; I&#39;m using version 3.8.1 of the grid and&#160;jQuery version 1.4.4.&#160; What we aim to do, is to load the structure of the grid when the page loads with the relevant data for the first page, and then&#160;use&#160;ajax requests&#160;after that to handle any subsequent data calls (paging, sorting, filtering, etc.)When the page loads, on the document ready handler of jQuery, I use the jqGridImport method to retrieve the structure of&#160;the grid.&#160; The code that I use for this looks something like:</p>
<div class="sourceRow ">$(function ()</div>
<div class="sourceRow ">{</div>
<div class="sourceRow ">&#160; $("#jqGrid").jqGrid(&#39;jqGridImport&#39;,</div>
<div class="sourceRow ">&#160; {</div>
<div class="sourceRow ">&#160;&#160;&#160; imptype: &#39;json&#39;,</div>
<div class="sourceRow ">&#160;&#160;&#160; impurl: &#39;/Home/GetGridStructure&#39;,</div>
<div class="sourceRow ">&#160;&#160;&#160; ajaxOptions:</div>
<div class="sourceRow ">&#160;&#160;&#160; {</div>
<div class="sourceRow ">&#160;&#160;&#160;&#160;&#160; cache: false</div>
<div class="sourceRow ">&#160;&#160;&#160;&#160;}</div>
<div class="sourceRow ">&#160; });</div>
<div class="sourceRow ">});</div>
<div class="sourceRow ">&#160;</div>
<div class="sourceRow ">and the html of the page contains:</div>
<div class="sourceRow ">&#60;table id="jqGrid"&#62;<br />&#60;/table&#62;<br />&#60;div id="jqGridPager"&#62;<br />&#60;/div&#62;</div>
<div class="sourceRow ">&#160;</div>
<p>In the&#160;json result&#160;that comes back, I include the only the necessary data that should be displayed on the first page of the grid, as well as all the other relevant information, like total number of pages, total records in query, etc.&#160; In my test example, the returned json result looks as follows:</p>
<p>{"grid":{"caption":"","width":500,"hoverrows":false,"url":"/Home/GetGridData","datatype":"json","rowNum":5,"colModel":[{"label":"ID","name":"ID","index":"ID","width":70,"title":false}],"gridview":true,"viewrecords":true,"shrinkToFit":false,"pager":"#jqGridPager","loadui":"none","hidegrid":false,"ajaxGridOptions":{"cache":false},"ajaxSelectOptions":{"cache":false}},"data":{"total":4,"page":1,"records":20,"rows":[{"id":"1","cell":["1"]},{"id":"2&#8243;,"cell":["2"]},{"id":"3&#8243;,"cell":["3"]},{"id":"4&#8243;,"cell":["4"]},{"id":"5&#8243;,"cell":["5"]}]}}</p>
<p>As you can see from this, I tell the grid (in the data tag) that there are a total of 4 pages and a total recordcount of 20.&#160; As mentioned previously, I do however only send through 5 rows of data to correspond with the grid parameter (rowNum = 5).&#160; I also set the url property of the grid to retrieve any subsequent data requests from the server. I would expect the pager of the grid to display "Page 1 of 4&#8243; and "View 1-5 of 20&#8243;, but instead I see "Page 1 of 1&#8243; and "View 1-5 of 5&#8243;. <br />Are there any&#160;properties in the grid that I should set to get this working, or am I approaching the problem in the wrong way?&#160; Please let me know if you require any additional information.&#160; Any help would be greatly appreciated.&#160;</p>
<p>Regards</p>
<p>Julian</p>
]]></description>
        	        	<pubDate>Mon, 22 Nov 2010 18:55:55 +0200</pubDate>
        </item>
</channel>
</rss>