<?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: problem with subgrid</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/problem-with-subgrid-1</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/problem-with-subgrid-1/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>dido on problem with subgrid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/problem-with-subgrid-1#p26480</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/problem-with-subgrid-1#p26480</guid>
        	        	<description><![CDATA[<p><span style="color: #ff0000;">hi, i need help for a simple subgrid that doesn&#39;t work...someone can have look my code please?<img class="spSmiley" style="margin:0" title="Cry" src="/blog/wp-content/forum-smileys/sf-cry.gif" alt="Cry" /><img class="spSmiley" style="margin:0" title="Cry" src="/blog/wp-content/forum-smileys/sf-cry.gif" alt="Cry" /><img class="spSmiley" style="margin:0" title="Cry" src="/blog/wp-content/forum-smileys/sf-cry.gif" alt="Cry" />...</span></p>
<p><span style="color: #ff0000;">my html:</span></p>
<p>&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&#62;</p>
<p>&#60;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&#62;</p>
<p>&#60;head&#62;</p>
<p>&#60;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&#62;</p>
<p>&#60;title&#62;My First Grid&#60;/title&#62;</p>
<p>&#60;link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.7.3.custom.css" /&#62;</p>
<p>&#60;link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" /&#62;</p>
</p>
<p>&#60;style type="text/css"&#62;</p>
<p>html, body {</p>
<p>margin: 0;</p>
<p>padding: 0;</p>
<p>font-size: 75%;</p>
<p>}</p>
<p>&#60;/style&#62;</p>
<p>&#60;script src="js/jquery-1.7.2.min.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#60;script src="js/i18n/grid.locale-en.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#60;script src="js/jquery.jqGrid.src.js" type="text/javascript"&#62;&#60;/script&#62;<img class="spSmiley" style="margin:0" title="Cry" src="/blog/wp-content/forum-smileys/sf-cry.gif" alt="Cry" /></p>
<p>&#60;script type="text/javascript"&#62;</p>
<p>$(function(){</p>
</p>
<p>$("#list").jqGrid({</p>
<p>url:&#39;montecrestese.php&#39;,</p>
<p>datatype: &#39;xml&#39;,</p>
<p>height: 400,</p>
<p>width: 1300,</p>
<p>mtype: &#39;GET&#39;,</p>
<p>colNames:[&#39;id_scheda&#39;,&#39;frazione&#39;, &#39;agglomerato&#39;,&#39;foglio&#39;,&#39;mappale&#39;,&#39;dest_uso1&#39;,&#39;dest_uso2&#39;,&#39;dest_uso3&#39;,&#39;piani&#39;,&#39;abitato&#39;,&#39;stato_edificio&#39;,&#39;ristrutturazione_consolidamenti&#39;,&#39;materiale_copertura&#39;,&#39;tipologia_copertura&#39;,&#39;comignoli&#39;,&#39;stato_copertura&#39;,&#39;foto&#39;],</p>
<p>colModel :[</p>
<p>{name:&#39;id_scheda&#39;, index:&#39;id_scheda&#39;, width:50},</p>
<p>{name:&#39;frazione&#39;, index:&#39;frazione&#39;, width:50},</p>
<p>{name:&#39;agglomerato&#39;, index:&#39;agglomerato&#39;, width:50, align:&#39;right&#39;},</p>
<p>{name:&#39;foglio&#39;, index:&#39;foglio&#39;, width:50, align:&#39;right&#39;},</p>
<p>{name:&#39;mappale&#39;, index:&#39;mappale&#39;, width:50, align:&#39;right&#39;},</p>
<p>{name:&#39;dest_uso1&#39;, index:&#39;dest_uso1&#39;, width:50, sortable:false},</p>
<p>{name:&#39;dest_uso2&#39;, index:&#39;dest_uso2&#39;, width:50, sortable:false},</p>
<p>{name:&#39;dest_uso3&#39;, index:&#39;dest_uso3&#39;, width:50, sortable:false},</p>
<p>{name:&#39;piani&#39;, index:&#39;piani&#39;, width:50, sortable:false},</p>
<p>{name:&#39;abitato&#39;, index:&#39;abitato&#39;, width:50, sortable:false},</p>
<p>{name:&#39;stato_edificio&#39;, index:&#39;stato_edificio&#39;, width:50, sortable:false},</p>
<p>{name:&#39;ristrutturazioni_consolidamenti&#39;, index:&#39;ristrutturazione_consolidamenti&#39;, width:50, sortable:false},</p>
<p>{name:&#39;materiale_copertura&#39;, index:&#39;materiale_copertura&#39;, width:50, sortable:false},</p>
<p>{name:&#39;tipologia_copertura&#39;, index:&#39;tipologia_copertura&#39;, width:50, sortable:false},</p>
<p>{name:&#39;comignoli&#39;, index:&#39;comignoli&#39;, width:50, sortable:false},</p>
<p>{name:&#39;stato_copertura&#39;, index:&#39;stato_copertura&#39;, width:50, sortable:false},</p>
<p>{name:&#39;foto&#39;, index:&#39;foto&#39;, width:50, sortable:false}</p>
<p>],</p>
<p>pager: &#39;#pager&#39;,</p>
<p>rowNum:100,</p>
<p>rowList:[10,20,30],</p>
<p>sortname: &#39;id_scheda&#39;,</p>
<p>sortorder: &#39;desc&#39;,</p>
<p>viewrecords: true,</p>
<p>gridview: true,</p>
<p>caption: &#39;tabella schede&#39;,</p>
<p>shrinkToFit: true,</p>
<p>altRows: true,</p>
<p>subGrid: true,</p>
<p>subGridUrl : "subgrid.php",</p>
<p>subGridModel : [</p>
<p>{</p>
<p>name  : [&#39;id_prospetti&#39;, &#39;orientamento&#39;, &#39;muratura&#39;, &#39;cantonali_gerarchizzati&#39;, &#39;elementi_interesse&#39;, &#39;elementi_interesse&#39;, &#39;loggiato&#39;, &#39;balconata&#39;,&#39;terrazza&#39;,&#39;ref_scheda&#39;],</p>
<p>width : [80, 80, 80, 80, 80, 80, 80, 80, 80, 80],</p>
<p>align : [&#39;left&#39;,&#39;left&#39;,&#39;right&#39;,&#39;right&#39;,&#39;right&#39;,&#39;right&#39;,&#39;right&#39;,&#39;right&#39;,&#39;right&#39;,&#39;right&#39;],</p>
<p>}</p>
<p>]</p>
<p>}).navGrid(&#39;#pager&#39;,{view:true, add:false, del:false, edit:false},</p>
<p>{}, // use default settings for edit</p>
<p>{}, // use default settings for add</p>
<p>{},  // delete instead that del:false we need this</p>
<p>{multipleSearch : true}, // enable the advanced searching</p>
<p>{closeOnEscape:true} /* allow the view dialog to be closed when user press ESC key*/</p>
<p>);</p>
<p>/*  $("#prospetti").jqGrid({</p>
<p>url:&#39;prospetti.php&#39;,</p>
<p>datatype: &#39;xml&#39;,</p>
<p>height: 400,</p>
<p>width: 1300,</p>
<p>mtype: &#39;GET&#39;,</p>
<p>colNames:[&#39;id_prospetti&#39;, &#39;orientamento&#39;, &#39;muratura&#39;, &#39;cantonali_gerarchizzati&#39;, &#39;elementi_interesse&#39;,&#39;loggiato&#39;,&#39;balconata&#39;,&#39;terrazza&#39;,&#39;ref_scheda&#39;],</p>
<p>colModel :[</p>
<p>{name:&#39;id_prospetti&#39;, index:&#39;id_prospetti&#39;, width:50},</p>
<p>{name:&#39;orientamento&#39;, index:&#39;orientamento&#39;, width:50},</p>
<p>{name:&#39;muratura&#39;, index:&#39;muratura&#39;, width:50, align:&#39;right&#39;},</p>
<p>{name:&#39;cantonali_gerarchizzati&#39;, index:&#39;cantonali_gerarchizzati&#39;, width:50, align:&#39;right&#39;},</p>
<p>{name:&#39;elementi_interesse&#39;, index:&#39;elementi_interesse&#39;, width:50, align:&#39;right&#39;},</p>
<p>{name:&#39;loggiato&#39;, index:&#39;loggiato&#39;, width:50, sortable:false},</p>
<p>{name:&#39;balconata&#39;, index:&#39;balconata&#39;, width:50, sortable:false},</p>
<p>{name:&#39;terrazza&#39;, index:&#39;terrazza&#39;, width:50, sortable:false},</p>
<p>{name:&#39;ref_scheda&#39;, index:&#39;ref_scheda&#39;, width:50, sortable:false},</p>
<p>],</p>
<p>pager: &#39;#pager2&#39;,</p>
<p>rowNum:100,</p>
<p>rowList:[10,20,30],</p>
<p>sortname: &#39;id_prospetti&#39;,</p>
<p>sortorder: &#39;desc&#39;,</p>
<p>viewrecords: true,</p>
<p>gridview: true,</p>
<p>caption: &#39;tabella prospetti&#39;,</p>
<p>shrinkToFit: true,</p>
<p>altRows: true,</p>
<p>}).navGrid(&#39;#pager2&#39;,{view:true, add:false, del:false, edit:false},</p>
<p>{}, // use default settings for edit</p>
<p>{}, // use default settings for add</p>
<p>{},  // delete instead that del:false we need this</p>
<p>{multipleSearch : true}, // enable the advanced searching</p>
<p>{closeOnEscape:true} /* allow the view dialog to be closed when user press ESC key</p>
<p>);</p>
<p>*/</p>
</p>
<p>});</p>
<p>&#60;/script&#62;</p>
</p>
<p>&#60;/head&#62;</p>
<p>&#60;body&#62;</p>
<p>&#60;table id="list"&#62;&#60;/table&#62;</p>
<p>&#60;div id="pager"&#62;&#60;/div&#62;</p>
<p>&#60;/body&#62;</p>
<p>&#60;/html&#62;</p>
</p>
<p><span style="color: #ff0000;">my php main:</span></p>
<p>&#60;?php</p>
<p>//include the information needed for the connection to MySQL data base server.</p>
<p>// we store here username, database and password</p>
<p>include("dbconfig.php");</p>
</p>
<p>// to the url parameter are added 4 parameters as described in colModel</p>
<p>// we should get these parameters to construct the needed query</p>
<p>// Since we specify in the options of the grid that we will use a GET method</p>
<p>// we should use the appropriate command to obtain the parameters.</p>
<p>// In our case this is $_GET. If we specify that we want to use post</p>
<p>// we should use $_POST. Maybe the better way is to use $_REQUEST, which</p>
<p>// contain both the GET and POST variables. For more information refer to php documentation.</p>
<p>// Get the requested page. By default grid sets this to 1.</p>
<p>$page = $_GET[&#39;page&#39;];</p>
</p>
<p>// get how many rows we want to have into the grid - rowNum parameter in the grid</p>
<p>$limit = $_GET[&#39;rows&#39;];</p>
</p>
<p>// get index row - i.e. user click to sort. At first time sortname parameter -</p>
<p>// after that the index from colModel</p>
<p>$sidx = $_GET[&#39;sidx&#39;];</p>
</p>
<p>// sorting order - at first time sortorder</p>
<p>$sord = $_GET[&#39;sord&#39;];</p>
</p>
<p>// if we not pass at first time index use the first column for the index or what you want</p>
<p>if(!$sidx) $sidx =1;</p>
</p>
<p>// connect to the MySQL database server</p>
<p>$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error());</p>
</p>
<p>// select the database</p>
<p>mysql_select_db($database) or die("Error connecting to db.");</p>
</p>
<p>// calculate the number of rows for the query. We need this for paging the result</p>
<p>$result = mysql_query("SELECT COUNT(*) AS count FROM schede");</p>
<p>$row = mysql_fetch_array($result,MYSQL_ASSOC);</p>
<p>$count = $row[&#39;count&#39;];</p>
</p>
<p>// calculate the total pages for the query</p>
<p>if( $count &#62; 0 &#38;&#38; $limit &#62; 0) {</p>
<p>$total_pages = ceil($count/$limit);</p>
<p>} else {</p>
<p>$total_pages = 0;</p>
<p>}</p>
</p>
<p>// if for some reasons the requested page is greater than the total</p>
<p>// set the requested page to total page</p>
<p>if ($page &#62; $total_pages) $page=$total_pages;</p>
</p>
<p>// calculate the starting position of the rows</p>
<p>$start = $limit*$page - $limit;</p>
</p>
<p>// if for some reasons start position is negative set it to 0</p>
<p>// typical case is that the user type 0 for the requested page</p>
<p>if($start &#60;0) $start = 0;</p>
</p>
<p>// the actual query for the grid data</p>
<p>$SQL = "SELECT * FROM schede ORDER BY $sidx $sord LIMIT $start , $limit";</p>
<p>$result = mysql_query( $SQL ) or die("Couldn&#39;t execute query.".mysql_error());</p>
</p>
<p>// we should set the appropriate header information. Do not forget this.</p>
<p>header("Content-type: text/xml;charset=utf-8");</p>
</p>
<p>$s = "&#60;?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39;?&#62;";</p>
<p>$s .=  "&#60;rows&#62;";</p>
<p>$s .= "&#60;page&#62;".$page."&#60;/page&#62;";</p>
<p>$s .= "&#60;total&#62;".$total_pages."&#60;/total&#62;";</p>
<p>$s .= "&#60;records&#62;".$count."&#60;/records&#62;";</p>
</p>
<p>// be sure to put text data in CDATA</p>
<p>while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {</p>
<p>$s .= "&#60;row id=&#39;". $row[&#39;id_scheda&#39;]."&#39;&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;id_scheda&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;frazione&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;agglomerato&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;foglio&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;mappale&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;dest_uso1&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;dest_uso2&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;dest_uso3&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;piani&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;abitato&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;stato_edificio&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;ristrutturazioni_consolidamenti&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;materiale_copertura&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;tipologia_copertura&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;comignoli&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;stato_copertura&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;&#60;![CDATA[". $row[&#39;foto&#39;]."]]&#62;&#60;/cell&#62;";</p>
<p>$s .= "&#60;/row&#62;";</p>
<p>}</p>
<p>$s .= "&#60;/rows&#62;";</p>
</p>
<p>echo $s;</p>
<p>?&#62;</p>
</p>
<p><span style="color: #ff0000;">my subgrid php:</span></p>
<p>&#60;?php</p>
<p>// get the id passed automatically to the request</p>
<p>$id = $_GET[&#39;id&#39;];</p>
<p>// get the invoice date passed to this request via params array in</p>
<p>//subGridModel. We do not use it here - this is only demostration</p>
<p>//$date_inv = $_GET[&#39;id&#39;];</p>
</p>
<p>suboptions = {</p>
<p>plusicon : "ui-icon-plus",</p>
<p>minusicon : "ui-icon-minus",</p>
<p>openicon: "ui-icon-carat-1-sw",</p>
<p>expandOnLoad:  true,</p>
<p>delayOnLoad : 50,</p>
<p>selectOnExpand : false,</p>
<p>reloadOnExpand : true</p>
<p>};</p>
</p>
<p>// connect to the database</p>
<p>$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error());</p>
</p>
<p>mysql_select_db($database) or die("Error conecting to db.");</p>
</p>
<p>// construct the query		suboptions = {</p>
<p>plusicon : "ui-icon-plus",</p>
<p>minusicon : "ui-icon-minus",</p>
<p>openicon: "ui-icon-carat-1-sw",</p>
<p>expandOnLoad:  false,</p>
<p>delayOnLoad : 50,</p>
<p>selectOnExpand : false,</p>
<p>reloadOnExpand : true</p>
<p>};</p>
</p>
<p>$SQL = "SELECT * FROM prospetti WHERE ref_scheda=".$id."";</p>
<p>$result = mysql_query( $SQL ) or die("Couldn?t execute query.".mysql_error());</p>
</p>
<p>// set the header information</p>
<p>if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {</p>
<p>header("Content-type: application/xhtml+xml;charset=utf-8");</p>
<p>} else {</p>
<p>header("Content-type: text/xml;charset=utf-8");</p>
<p>}</p>
</p>
<p>echo "&#60;?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39;?&#62;";</p>
<p>echo "&#60;rows&#62;";</p>
<p>// be sure to put text data in CDATA</p>
<p>while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {</p>
<p>echo "&#60;row&#62;";</p>
<p>echo "&#60;cell&#62;". $row[id_prospetti]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;". $row[orientamento]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;". $row[muratura]]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;". $row[cantonali_gerarchizzati]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;". $row[elementi_interesse]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;". $row[loggiato]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;". $row[balconata]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;". $row[terrazza]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;". $row[ref_scheda]."&#60;/cell&#62;";</p>
<p>echo "&#60;/row&#62;";</p>
<p>}</p>
<p>echo "&#60;/rows&#62;";</p>
</p>
<p>?&#62;</p>
]]></description>
        	        	<pubDate>Thu, 26 Apr 2012 20:56:10 +0300</pubDate>
        </item>
</channel>
</rss>