<?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: Subgrid data not loading</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/subgrid-data-not-loading</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/subgrid-data-not-loading/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>olefrank on Subgrid data not loading</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/subgrid-data-not-loading#p28460</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/subgrid-data-not-loading#p28460</guid>
        	        	<description><![CDATA[<p>I&#39;m new to JqGrid. I&#39;m trying to make a grid with products. For each product I want a subgrid showing orders.</p>
<p>I can&#39;t load data in the subgrids. The &#39;load_sub_data_json.php&#39; is never loaded...</p>
<p>Here&#39;s the JS my HTML file:</p>
<pre class="default prettyprint prettyprinted"><p><input type='button' class='sfcodeselect' name='sfselectit1939' value='Select Code' data-codeid='sfcode1939' /></p><div class='sfcode' id='sfcode1939'>&#60;pre&#62;
jQuery(document).ready(function() { 
  $("#list").jqGrid({
    height: &#39;auto&#39;,
    blockui: true,
    altRows: true,
    loadonce: true,
    url:&#39;load_main_data_json.php&#39;,
    datatype: &#39;json&#39;,
    mtype: &#39;GET&#39;,
    colNames:[&#39;ProductCode&#39;,&#39;ProductName&#39;, &#39;ProductVendor&#39;],
    colModel :[ 
      {name:&#39;productcode&#39;, index:&#39;productcode&#39;, width:100, align:&#39;right&#39;}, 
      {name:&#39;productname&#39;, index:&#39;productname&#39;, width:280, align:&#39;right&#39;}, 
      {name:&#39;productvendor&#39;, index:&#39;productvendor&#39;, width:200, align:&#39;right&#39;}
    ],
    rowNum:35,
    rowList:[25,50,75,100,125,150,175,200],
    sortname: &#39;productcode&#39;,
    sortorder: &#39;desc&#39;,
    viewrecords: true,
    caption: &#39;My first grid&#39;,
    subGrid: true,
    subGridUrl: &#39;load_sub_data_json.php&#39;,
    subGridModel: [
      { name  : [&#39;Order number&#39;,&#39;Order date&#39;,&#39;Shipped date&#39;,&#39;Comments&#39;],
        index : [&#39;orderNumber&#39;, &#39;orderDate&#39;, &#39;shippedDate&#39;, &#39;comments&#39;], 
        width : [55,100,100,200],
        align : [&#39;right&#39;,&#39;right&#39;,&#39;right&#39;,&#39;right&#39;],
        params: [&#39;productcode&#39;]
      } 
    ]
  });
});
&#60;/pre&#62;</div></pre>
<p>And this is my php-file loading data to the subgrid:</p>
<pre class="default prettyprint prettyprinted"><p><input type='button' class='sfcodeselect' name='sfselectit3255' value='Select Code' data-codeid='sfcode3255' /></p><div class='sfcode' id='sfcode3255'>&#60;pre&#62; 

include("dbconfig.php");

$id = $_REQUEST[&#39;id&#39;];
$productCode = $_REQUEST[&#39;productcode&#39;]; // param passed by query


// connect to the database
$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " .     mysql_error());

// select database
mysql_select_db($database) or die("Error conecting to db.");

// select columns
$SQL = "select o.orderNumber, o.orderDate, o.shippedDate, o.comments from orderdetails d inner join orders o on o.orderNumber = d.orderNumber where d.productcode=&#39;" . $id. "&#39;;";

$result = mysql_query( $SQL ) or die("CouldnÂ’t execute query.".mysql_error());

$response = new stdClass;
$i=0;
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
    $response-&#62;rows[$i][&#39;id&#39;]=$row[&#39;orderNumber&#39;];
    $response-&#62;rows[$i]    [&#39;cell&#39;]=array($row[&#39;orderNumber&#39;],$row[&#39;orderDate&#39;],$row[&#39;shippedDate&#39;],$row[&#39;comments&#39;]);
    $i++;
}

echo json_encode($response);

&#60;/pre&#62;</div></pre>
]]></description>
        	        	<pubDate>Fri, 15 Mar 2013 16:37:10 +0200</pubDate>
        </item>
</channel>
</rss>