<?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: How to read nested json list in jqgrid</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-read-nested-json-list-in-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/how-to-read-nested-json-list-in-jqgrid/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>Damu on How to read nested json list in jqgrid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-read-nested-json-list-in-jqgrid#p30029</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-read-nested-json-list-in-jqgrid#p30029</guid>
        	        	<description><![CDATA[<p>This is my Grid data</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit3214' value='Select Code' data-codeid='sfcode3214' /></p>
<div class='sfcode' id='sfcode3214'>
<p>&#60;script&#62;</p>
<pre class=&#34;default prettyprint prettyprinted&#34;></pre>
<pre class=&#34;&#34;default&#34;></pre>
<pre class=&#34;&#34;default&#34;>  $(document).ready(function (){
            var i; i=0;
    $.ajax({
        url: &#39;/display_rpt_expectedtableSchema?rpt_step_id=&#60;%=@rpt_step_id%&#62;&#38;header_data=true&#39;,
        success: function (data, st) {
            if (st == &#34;success&#34;) {
                var columnData = jQuery.parseJSON(data)
               // for(i=0;i&#60;columnData.source.length; i++)  {alert(&#39;how many loops&#39;); alert(i);
                jQuery(&#34;#schemalist&#34;).jqGrid({
                    //url : &#39;/display_rpt_expectedtableSchema?rpt_step_id=&#60;%=@rpt_step_id%&#62;&#38;header_data=false&#39;,
                    datastr: columnData.source,
                    pager: &#39;#schemaPager&#39;,
                    datatype: &#34;jsonstring&#34;,
                    colNames: [&#39;ExpTableName&#39;,&#39;ExpColumn&#39;, &#39;ExpType&#39;, &#39;ExpSize&#39;],
                    cmTemplate: { title: false },
                    //colModel:ColM,
                    /*colModel:  [
                        {name:&#39;tableName&#39;,index:&#39;tableName&#39;, width:145,jsonmap:&#39;columns&#39;+&#39;.&#39;+i+&#39;.&#39;+&#39;tableName&#39;},</pre>
<pre class=&#34;&#34;default&#34;>                        {name:&#39;name&#39;,index:&#39;name&#39;, width:145,jsonmap:&#39;columns&#39;+&#39;.&#39;+i+&#39;.&#39;+&#39;name&#39;},
                        {name:&#39;type&#39;,index:&#39;type&#39;, width:145,jsonmap:&#39;columns&#39;+&#39;.&#39;+i+&#39;.&#39;+&#39;type&#39;},
                        {name:&#39;size&#39;,index:&#39;size&#39;, width:145,jsonmap:&#39;columns&#39;+&#39;.&#39;+i+&#39;.&#39;+&#39;size&#39;}
                    ],*/
                    colModel:  [
                        {name:&#39;tableName&#39;,index:&#39;tableName&#39;, width:145,jsonmap:&#39;tableName&#39;},
                        {name:&#39;name&#39;,index:&#39;name&#39;, width:145,jsonmap:&#39;name&#39;},
                        {name:&#39;type&#39;,index:&#39;type&#39;, width:145,jsonmap:&#39;type&#39;},
                        {name:&#39;size&#39;,index:&#39;size&#39;, width:145,jsonmap:&#39;size&#39;}
                    ],

                    //jsonReader:{repeatitems: false,root:&#39;source&#39;+&#39;.&#39;+i+&#39;.&#39;+&#39;columns&#39;},
                    jsonReader:{repeatitems: false,root:&#39;source.0.columns&#39;},
                    rowNum: 25,
                    viewrecords: true,
                    caption: &#34;Expected Schema&#34;,
                    height: 600,
                    width: 600,
                    //multiselect: true,
                    autoFitColumns: true,
                    loadonce: true,
                    autoencode: true,
                    shrinkToFit: false,
                    ignoreCase: true
                });

                    $(&#34;#schemalist&#34;).jqGrid(&#39;navGrid&#39;,&#39;#schemaPager&#39;,{edit:false,add:false,del:false});

            }

      //      }
        },
        error: function () {
            alert(&#34;Error with AJAX callback&#34;);
        }
    });

  });</pre>
</div>
<pre class="default prettyprint prettyprinted"><p><strong>and Here is my JSON Object</strong></p>
<p>{"source":[{"id":1,"columns":[{"name":"Jdate","type":"Date","size":"0","tableName":"c1"},</p>
<p>{"name":"CustId","type":"Int","size":"0","tableName":"c2"},</p>
<p>{"name":"Jdate","type":"Date","size":"0","tableName":"c3"},</p>
<p>{"name":"Jdate","type":"Date","size":"0","tableName":"c4"},</p>
<p>{"name":"Jdate","type":"Date","size":"0","tableName":"c5"}]},</p>
<p>{"id":2,"columns":[{"name":"Amt","type":"Money","size":" 0","tableName":"Loan"},</p>
<p>{"name":"Tenure","type":"int","size":" 0","tableName":"Loan"}]},</p>
<p>{"id":3,"columns":[{"name":"Amt","type":"Money","size":" 0","tableName":"xyz"},</p>
<p>{"name":"Tenure","type":"int","size":" 0","tableName":"xyz"}]}]}&#160;</p>
<br />
<p><strong>Data displaying in grid with first list which is "ID":1 but not "id" 2,3</strong></p>
<p>({"name":"Jdate","type":"Date","size":"0","tableName":"c1"},</p>
<p>{"name":"CustId","type":"Int","size":"0","tableName":"c2"},</p>
<p>{"name":"Jdate","type":"Date","size":"0","tableName":"c3"},</p>
<p>{"name":"Jdate","type":"Date","size":"0","tableName":"c4"},</p>
<p>{"name":"Jdate","type":"Date","size":"0","tableName":"c5"})</p>
<br />
<p><strong>Because Here I have used JsonReader as root: &#39;source.0.columns&#39;.</strong></p>
<p>My requirement is to load whole json object data in the above grid (i.e have to load id &#39;1&#39;,&#39;2&#39;,&#39;3&#39;)</p>
<p>I tried to loop it in jsonReader:{repeatitems: false,root:&#39;source&#39;+&#39;.&#39;+i+&#39;.&#39;+&#39;columns&#39;} by getting count of the "columns" list in the object (looping the whole the grid). But Grid is loading values for first json list and not loading other 2 lists.</p>
<p>Is there any other approach to load given json object with the data in grid? Is there any way to loop the jsonreader to display all the jsonlist data?</p>
<p>How to read this kind json data in grid. am I going in right direction?</p>
<p>Please help me on this.</p>
</pre>
]]></description>
        	        	<pubDate>Wed, 25 Dec 2013 05:46:29 +0200</pubDate>
        </item>
</channel>
</rss>