<?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: Loading JSON Data techniques and sorting issue</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/loading-json-data-techniques-and-sorting-issue</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/loading-json-data-techniques-and-sorting-issue/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on Loading JSON Data techniques and sorting issue</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/loading-json-data-techniques-and-sorting-issue#p24529</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/loading-json-data-techniques-and-sorting-issue#p24529</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>To complex solution.</p>
<p>You will need just to write some server side logic when sort is performed. Just read what we pass as parameters when we do sort.</p>
</p>
<p>Regards</p>
]]></description>
        	        	<pubDate>Mon, 05 Sep 2011 19:47:25 +0300</pubDate>
        </item>
        <item>
        	<title>dzangger67 on Loading JSON Data techniques and sorting issue</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/loading-json-data-techniques-and-sorting-issue#p24515</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/loading-json-data-techniques-and-sorting-issue#p24515</guid>
        	        	<description><![CDATA[<p>I just added this:</p>
<pre></pre>
<pre>                           complete:&#160;function&#160;(xhr,&#160;stat)&#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;if&#160;(stat&#160;==&#160;"success")&#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;var&#160;data&#160;=&#160;JSON.parse(xhr.responseText);
	&#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;$("#list").jqGrid(&#39;setGridParam&#39;,&#160;{&#160;datatype:&#160;&#39;jsonstring&#39;,&#160;datastr:&#160;data&#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;$("#list").trigger(&#39;reloadGrid&#39;);
	&#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;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</pre>
<p>and it seems to work.  I just hope this is the correct method of doing this.</p>
]]></description>
        	        	<pubDate>Sun, 04 Sep 2011 03:54:55 +0300</pubDate>
        </item>
        <item>
        	<title>dzangger67 on Loading JSON Data techniques and sorting issue</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/loading-json-data-techniques-and-sorting-issue#p24514</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/loading-json-data-techniques-and-sorting-issue#p24514</guid>
        	        	<description><![CDATA[<p>Hello.&#160; After many attempts, and too many searches to mention, I&#39;m finally able to load JSON data from my web service. &#160; Here is what I have:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #3366ff;">$("#list").jqGrid({<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; url: &#39;FileServices/GetList/JSA&#39;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: function (postdata) {<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $.ajax({<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; type: "GET",<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; contentType: "application/json; charset=utf-8&#8243;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; dataType: "json",<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; data: postdata,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; url: "FileServices/GetList/JSA",<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; complete: function (xhr, stat) {<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; if (stat == "success") {<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; var jsonObject = (eval("(" + xhr.responseText + ")"));<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; $(&#39;#list&#39;)[0].addJSONData(JSON.parse(jsonObject));<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; }<br />&#160;&#160; &#160;&#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;&#160;&#160;&#160; });<br />&#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; jsonReader: { root: "rows", page: "page", total: "total", <br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;records: "records", repeatitems: true, cell: "cell", id: "id" },<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames: [&#39;Id&#39;, &#39;Number&#39;, &#39;Facility&#39;, &#39;Department&#39;, &#39;Category&#39;, &#39;Job Title&#39;],<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel: [<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Id&#39;, index: &#39;Id&#39;, width: 55 },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Number&#39;, index: &#39;Number&#39;, width: 90 },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Facility&#39;, index: &#39;Facility&#39;, width: 80 },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Department&#39;, index: &#39;Department&#39;, width: 80 },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Category&#39;, index: &#39;Category&#39;, width: 80 },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Job_Title&#39;, index: &#39;Job_Title&#39;, width: 150, sortable: 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; pager: &#39;#pager&#39;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowNum: 10,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowList: [10, 20, 30],<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortname: &#39;Id&#39;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; height: &#39;auto&#39;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortorder: &#39;desc&#39;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; viewrecords: true,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; gridview: true,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; caption: &#39;My first grid&#39;<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }).navGrid("#pager");</span></p>
<p>When I try to click on a column to sort, it doesn&#39;t work.&#160; I read that you need the reloadGrid trigger added but I&#39;m not sure what that would go.&#160; I tried it in a couple of places and that seemed to send the grid in some crazy infinite loop or something.</p>
<p>Now using the code below, the data loads fine and the sorting works great.&#160; But the data call is done outside of the main call.&#160; I like the idea of having everything in the single call (like above).</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #339966;">$("#list").jqGrid({<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; url: &#39;FileServices/GetList/JSA&#39;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: &#39;jsonstring&#39;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jsonReader: { root: "rows", page: "page", total: "total", records: "records", repeatitems: true, cell: "cell",&#160; id: "id" },<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mtype: &#39;GET&#39;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames: [&#39;Id&#39;, &#39;Number&#39;, &#39;Facility&#39;, &#39;Department&#39;, &#39;Category&#39;, &#39;JobTitle&#39;],<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel: [<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Id&#39;, index: &#39;Id&#39;, width: 55 },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Number&#39;, index: &#39;Number&#39;, width: 90 },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Facility&#39;, index: &#39;Facility&#39;, width: 80 },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Department&#39;, index: &#39;Department&#39;, width: 80 },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Category&#39;, index: &#39;Category&#39;, width: 80 },<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; { name: &#39;Job_Title&#39;, index: &#39;Job_Title&#39;, width: 150, sortable: 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; pager: &#39;#pager&#39;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowNum: 10,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowList: [10, 20, 30],<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortname: &#39;Id&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; height: &#39;auto&#39;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortorder: &#39;desc&#39;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; viewrecords: true,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; gridview: true,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; caption: &#39;My first grid&#39;<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }).navGrid("#pager&#8243;);</span></p>
<p>&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $("#list").clearGridData();</p>
<p>&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $.ajax({<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; type: "GET",<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; contentType: "application/json; charset=utf-8&#8243;,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; dataType: "json",<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; data: null,<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; url: "FileServices/GetList/JSA",<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; complete: function (xhr, status) {<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var data = JSON.parse(xhr.responseText);<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $("#list").jqGrid(&#39;setGridParam&#39;, { datatype: &#39;jsonstring&#39;, datastr: data });<br />&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $("#list").trigger(&#39;reloadGrid&#39;);<br />&#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; });</p>
</p>
<p>Does anything stand out to what I&#39;m missing?&#160;</p>
<p>Thank you very much!</p></p>
]]></description>
        	        	<pubDate>Sun, 04 Sep 2011 01:33:12 +0300</pubDate>
        </item>
</channel>
</rss>