<?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: Can't get grid to display JSON data...</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/cant-get-grid-to-display-json-data</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/cant-get-grid-to-display-json-data/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>simspace on Can't get grid to display JSON data...</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-get-grid-to-display-json-data#p19664</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-get-grid-to-display-json-data#p19664</guid>
        	        	<description><![CDATA[<p>Maybe I should explain my situation a little better&#8230;</p>
<p><strong>*&#160;</strong>I have a search page with multiple fields.</p>
<p>&#160;&#160; Not all fields are required, so there can be any combo of 1 to 7 fields.</p>
<p><strong>*&#160;</strong>The search page is submitted, sending json formatted data back to the server.</p>
<p>&#160;&#160; This data is the SQL WHERE clause parameters.</p>
<p><strong>*&#160;</strong>The SQL is executed on the server.&#160;</p>
<p><strong>*&#160;</strong>The grid page is sent back from the server with the JSON formatted DB results in the http response.</p>
<p><strong>*&#160;</strong>The $j(document).ready function fires to display the datagrid and run the code to load the grid&#8230;<br /><span style="color: #3366ff;"><strong>&#160;&#160; $j("#leadlist").jqGrid(&#39;addJSONData&#39;, </strong><em><strong>j</strong></em></span><span style="color: #3366ff;"><em><strong>son-data-from-httpResponse</strong></em></span><span style="color: #3366ff;"><strong>);</strong></span><strong>&#160;<br />&#160;</strong><br /><strong>*&#160;</strong>You may be asking "<em>how does the json-data-from-httpResponse get added to the &#39;addJSONData&#39; call?</em>" The code above, that calls the &#39;addJSONData&#39; method is built dynamically on the server before the grid page s returned to the client. This is the server-side Coldfusion/Mach-ii code to returns the grid page. What is <em>not </em>shown is the js code for the grid itself.</p>
<p><span style="color: #3366ff;"><strong>&#60;cfoutput&#62;<br />&#160;&#160; &#160; &#60;script type="text/javascript"&#62;<br />&#160;&#160; &#160; &#160; &#160; &#160;$j("##leadlist").jqGrid(&#39;addJSONData&#39;, &#39;#event.getArgs().jsonDataToBeReturned#&#39;);<br />&#160;&#160; &#160; &#60;/script&#62;<br />&#160;&#160; &#160; &#60;table id="leadlist"&#62;&#60;/table&#62;<br />&#160;&#160; &#160; &#60;div id="leadpager"&#62;&#60;/div&#62;<br />&#60;/cfoutput&#62;<br />&#160;</strong></span> </p>
<ul>
</ul>
<p>So&#8230;</p>
<ul>
<li>The search and datagrid pages are two&#160;separate&#160;pages&#8230; two separate http requests.</li>
<li>The SQL WHERE clause is built dynamically using the data from the submitted search page.</li>
<li>Using&#160;JavaScript,&#160;I need to load the grid from the HTTP response that builds the datagrid page.&#160;</li>
</ul>
<p>Sorry for all the detail. I just wanted to clarify my situation.</p>
<p>Thanks!</p>
<p>Chris</p>
]]></description>
        	        	<pubDate>Fri, 10 Sep 2010 18:07:04 +0300</pubDate>
        </item>
        <item>
        	<title>simspace on Can't get grid to display JSON data...</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-get-grid-to-display-json-data#p19663</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-get-grid-to-display-json-data#p19663</guid>
        	        	<description><![CDATA[<p>Thanks for your reply.</p>
<ul>
<li>My json data is in the {"name":"value","name2&#8243;:"value2&#8243;} format. I ran the data through jsonlint.com and it is valid json. You think the array brackets messing up the grid?</li>
<li>Also, I&#39;m not loading my json data from a file. I&#39;m getting the data off the http response. As a result&#160;I need to call the jqGrid method "&#39;addJSONData&#39;" to load the data into the grid. That is why there is no url parameter on my grid as shown above.</li>
</ul>
<p>Any ideas what may be wrong with my code above?&#160;</p>
<p>Thanks!</p>
<p>Chris</p>
]]></description>
        	        	<pubDate>Fri, 10 Sep 2010 17:34:53 +0300</pubDate>
        </item>
        <item>
        	<title>mikeerickson on Can't get grid to display JSON data...</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-get-grid-to-display-json-data#p19645</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-get-grid-to-display-json-data#p19645</guid>
        	        	<description><![CDATA[<p>Does the grid display and it just has empty data, or does the grid not even display. &#160;</p>
</p>
<p>A few things:</p>
</p>
<p>1. &#160;Format JSON should be&#160;</p>
</p>
<p>&#160;&#160;{"name":"value","name2":"value2"}</p>
</p>
<p>I have the following construct that works just fine (loads file from a file containing JSON data)</p>
</p>
<p>$("#masterList").jqGrid({</p>
<p>url: "sample.json",</p>
<p>datatype: "json",</p>
<p>colNames: [&#39;Inv&#39;,&#39;Date&#39;, &#39;Client&#39;, &#39;Amount&#39;,&#39;Tax&#39;,&#39;Total&#39;,&#39;Notes&#39;],</p>
<p>colModel:[</p>
<p>{name:&#39;id&#39;,index:&#39;id&#39;, width:60, editable:true, sorttype:&#39;int&#39;,align:"center"},</p>
<p>{name:&#39;invdate&#39;,index:&#39;invdate&#39;, width:90, sorttype:&#39;date&#39;, formatter:&#39;date&#39;, datefmt:&#39;d/m/Y&#39;,align:"center"},</p>
<p>{name:&#39;name&#39;,index:&#39;name&#39;, width:100},</p>
<p>{name:&#39;amount&#39;,index:&#39;amount&#39;, width:80, align:"right", sorttype:&#39;number&#39;,formatter:&#39;currency&#39;},</p>
<p>{name:&#39;tax&#39;,index:&#39;tax&#39;, width:80, align:"right",sorttype:&#39;number&#39;,formatter:&#39;currency&#39;},</p>
<p>{name:&#39;total&#39;,index:&#39;total&#39;, width:80,align:"right",sorttype:&#39;number&#39;,formatter:&#39;currency&#39;},</p>
<p>{name:&#39;note&#39;,index:&#39;note&#39;, width:120, sortable:false,editable:true}</p>
<p>],</p>
<p>rowNum: 10,</p>
<p>forceFit: true,</p>
<p>rowList: [5,10,20,30],</p>
<p>loadonce: true,</p>
<p>height: 200,</p>
<p>width: 640,</p>
<p>pager: &#39;#masterPager&#39;,</p>
<p>sortname: &#39;id&#39;,</p>
<p>viewrecords: true,</p>
<p>sortorder: "desc",</p>
<p>});</p></p>
]]></description>
        	        	<pubDate>Fri, 10 Sep 2010 04:47:04 +0300</pubDate>
        </item>
        <item>
        	<title>simspace on Can't get grid to display JSON data...</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-get-grid-to-display-json-data#p19642</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-get-grid-to-display-json-data#p19642</guid>
        	        	<description><![CDATA[<p>Hi,</p>
<p>I need to load my jqGrid manually, so I am not using the url parameter in the grid.</p>
<p>I get my data back from the server as JSON.</p>
<p>I can&#39;t get the grid to display&#160;the data. Would you please tell me what I may be doing wrong in the code below?</p>
<p>Thanks!</p>
<p>Chris</p>
</p>
<p><strong><span style="text-decoration: underline;">Here&#39;s my sample JSON data:</span></strong></p>
<p><span style="color: #3366ff;">[{"id":40,"email":"some@email.org","name":"rick tester","comment":"some comment text","phone":"555-666-7777"}] </span></p>
</p>
<p><strong><span style="text-decoration: underline;">Here&#39;s my code to load the grid:</span></strong></p>
<p><span style="color: #3366ff;">$j("#leadlist").jqGrid(&#39;addJSONData&#39;, </span><em><span style="color: #3366ff;">varJsonData</span></em><span style="color: #3366ff;">)</span>; &#160;<span style="color: #339966;">// </span><em><span style="color: #339966;">varJsonData&#160;</span></em><span style="color: #339966;">contains the json data from the server...</span></p>
</p>
<p><strong><span style="text-decoration: underline;">Here&#39;s my grid</span></strong></p>
<p><span style="color: #3366ff;">$j("#leadlist").jqGrid({</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">datatype: &#39;json&#39;,</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">altRows:true,</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">colNames:[&#39;id&#39;, &#39;name&#39;,&#39;email&#39;,&#39;phone&#39;,&#39;comment&#39;],</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">colModel :[</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">{name:&#39;id&#39;, index:&#39;id&#39;, key:true, formatter:&#39;integer&#39;, sorttype:&#39;int&#39;, width:55},</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">{name:&#39;name&#39;, index:&#39;name&#39;, width:150},</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">{name:&#39;email&#39;, index:&#39;email&#39;, width:150, sortable:false},</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">{name:&#39;phone&#39;, index:&#39;phone&#39;, width:100, align:&#39;center&#39;, sortable:false},</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">{name:&#39;comment&#39;, index:&#39;comment&#39;, width:150, sortable:false}</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">],</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">jsonReader : {</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">root: function (obj) { return obj; },</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">cell: function (obj) { return obj; },</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">page: function (obj) { return 1; },</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">total: function (obj) { return 1; },</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">records: function (obj) { return obj.length; }</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">},</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">ondblClickRow: function(rowid, rowndx, colndx, objEvent)</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">{</span></p>
<p style="padding-left: 60px;"><span style="color: #3366ff;">top.location.href = &#39;/counselor-hub/lead-profile/id/&#39;+rowid;</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">},</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">width:750,</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">height:400,</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">pager: &#39;#leadpager&#39;,</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">rowNum:30,</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">rowList:[15,30,60,100],</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">sortname: &#39;name&#39;,</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">sortorder: &#39;desc&#39;,</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">viewrecords: true,</span></p>
<p style="padding-left: 30px;"><span style="color: #3366ff;">caption: &#39;Leads&#39;</span></p>
<p><span style="color: #3366ff;">});</span></p></p>
]]></description>
        	        	<pubDate>Fri, 10 Sep 2010 01:58:09 +0300</pubDate>
        </item>
</channel>
</rss>