<?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: Adding data in a subgrid</title>
	<link>http://www.trirand.com/blog/?page_id=393/treegrid/adding-data-in-a-subgrid</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/treegrid/adding-data-in-a-subgrid/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on Adding data in a subgrid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/adding-data-in-a-subgrid#p14137</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/adding-data-in-a-subgrid#p14137</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>This is a wrong forum. Please post it here!</p>
<p><a href="http://www.trirand.net/forum/" rel="nofollow" target="_blank">http://www.trirand.net/forum/</a></p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Fri, 22 Jan 2010 11:55:21 +0200</pubDate>
        </item>
        <item>
        	<title>fede78 on Adding data in a subgrid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/adding-data-in-a-subgrid#p13942</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/adding-data-in-a-subgrid#p13942</guid>
        	        	<description><![CDATA[<p>I&#39;ve a grid with a subgrid. I&#39;ve enabled the &#39;add&#39; and &#39;edit&#39; options in the subgrid, show the form correctly but when clicked the save button the data are not saved in the database.</p>
<p>Why?</p>
</p>
<p>the grid code: gridavisos.php</p>
<p>&#60;?php<br />require_once &#39;jq-config.php&#39;;<br />// include the jqGrid Class<br />require_once ABSPATH."jqGrid.php";<br />// include the driver class<br />require_once ABSPATH."jqGridPdo.php";<br />// Connection to the server<br />$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);<br />// Tell the db that we use utf-8<br />$conn-&#62;query("SET NAMES utf8");<br />// Create the jqGrid instance<br />$grid = new jqGridRender($conn);<br />// this table is 1252 encoded, so we need to tell the grid<br />// Set the table data source<br />$grid-&#62;setTable(&#39;clientes&#39;);<br />// set the ouput format to xml since json have problems<br />$grid-&#62;dataType = &#39;xml&#39;;<br />// Let the grid create the model<br />$grid-&#62;setColModel();<br />// Set the url from where we obtain the data<br />$grid-&#62;setUrl(&#39;gridavisos.php&#39;);<br />// Set some grid options<br />$grid-&#62;setGridOptions(array("height"=&#62;400,"hoverrows"=&#62;true,"autowidth"=&#62;true,"rowNum"=&#62;20,"rowList"=&#62;array(20,50,100),"sortname"=&#62;"nombre"));<br />$grid-&#62;setColProperty("cif", array("width"=&#62;90));<br />$grid-&#62;setColProperty("cp", array("width"=&#62;45));<br />$grid-&#62;setColProperty("provincia", array("width"=&#62;80));<br />$grid-&#62;setColProperty("telefono", array("width"=&#62;60));<br />// We can hide some columns<br />$grid-&#62;setColProperty("id_cliente", array("hidden"=&#62;true));<br />// set labels in the header<br />$grid-&#62;setColProperty("nombre", array("label"=&#62;"Nombre"));<br />$grid-&#62;setColProperty("cif", array("label"=&#62;"NIF"));<br />$grid-&#62;setColProperty("direccion", array("label"=&#62;"Direcci&#243;n")); <br />$grid-&#62;setColProperty("cp", array("label"=&#62;"CP"));<br />$grid-&#62;setColProperty("poblacion", array("label"=&#62;"Poblaci&#243;n"));<br />$grid-&#62;setColProperty("provincia", array("label"=&#62;"Provincia"));<br />$grid-&#62;setColProperty("email", array("label"=&#62;"Email"));<br />$grid-&#62;setColProperty("telefono", array("label"=&#62;"Tel&#233;fono")); <br />// Enable toolbar searching<br />$grid-&#62;toolbarfilter = true;<br />$grid-&#62;setFilterOptions(array("stringResult"=&#62;true));<br />$grid-&#62;setSubGridGrid("subgridavisos.php");<br />// Enjoy<br />$grid-&#62;renderGrid(&#39;#grid&#39;,&#39;#pager&#39;,true, null, null, true,true);<br />$conn = null;<br />?&#62;</p>
</p>
<p>the subgrid code: gridsubavisos.php</p>
<p>&#60;?php<br />require_once &#39;jq-config.php&#39;;<br />// include the jqGrid Class<br />require_once ABSPATH."jqGrid.php";<br />// include the driver class<br />require_once ABSPATH."jqGridPdo.php";<br />// Connection to the server<br />$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);<br />// Tell the db that we use utf-8<br />$conn-&#62;query("SET NAMES utf8");<br />// Get the needed parameters passed from the main grid<br />// By default we add to postData subgrid and rowid parameters in the main grid<br />$subtable = jqGridUtils::Strip($_REQUEST["subgrid"]);<br />$rowid = jqGridUtils::Strip($_REQUEST["rowid"]);<br />if(!$subtable &#38;&#38; !$rowid) die("Missed parameters");<br />// Create the jqGrid instance<br />$grid = new jqGridRender($conn);<br />// Write the SQL Query<br />$grid-&#62;SelectCommand = "SELECT * FROM avisos WHERE id_cliente = ?";<br />// set the ouput format to json<br />$grid-&#62;dataType = &#39;json&#39;;<br />// Let the grid create the model<br />$grid-&#62;setColModel(null,array(&#38;$rowid));<br />// Set the url from where we obtain the data<br />$grid-&#62;setUrl(&#39;subgridavisos.php&#39;);<br />// Set some grid options<br />$grid-&#62;setGridOptions(array(<br />&#160;&#160;&#160; "hoverrows"=&#62;true,"autowidth"=&#62;true,<br />&#160;&#160;&#160; "rowNum"=&#62;10,<br />&#160;&#160;&#160; "sortname"=&#62;"id_aviso",<br />&#160;&#160;&#160; "height"=&#62;70,<br />&#160;&#160;&#160; "postData"=&#62;array("subgrid"=&#62;$subtable,"rowid"=&#62;$rowid)));<br />// Change some property of the field(s)<br />$grid-&#62;setColProperty("fecha", array(<br />&#160;&#160;&#160; "formatter"=&#62;"date",<br />&#160;&#160;&#160; "formatoptions"=&#62;array("srcformat"=&#62;"Y-m-d","newformat"=&#62;"d/m/Y"),<br />&#160;&#160;&#160; "search"=&#62;false<br />&#160;&#160;&#160; )<br />);<br />$grid-&#62;setColProperty("fecha", array("width"=&#62;15));<br />// We can hide some columns<br />//$grid-&#62;setColProperty("id_aviso", array("hidden"=&#62;true));<br />//$grid-&#62;setColProperty("id_cliente", array("hidden"=&#62;true));<br />// set labels in the header<br />$grid-&#62;setColProperty("fecha", array("label"=&#62;"Fecha"));<br />$grid-&#62;setColProperty("descripcion", array("label"=&#62;"Descripci&#243;n"));<br />$grid-&#62;navigator = true;<br />$grid-&#62;setNavOptions(&#39;navigator&#39;, array("excel"=&#62;false,"add"=&#62;true,"edit"=&#62;true,"del"=&#62;true,"view"=&#62;true));<br />//config dialogs<br />$grid-&#62;setNavOptions(&#39;add&#39;,array("closeOnEscape"=&#62;true,"closeAfterAdd"=&#62;true,"reloadAfterSubmit"=&#62;true));<br />$grid-&#62;setNavOptions(&#39;edit&#39;,array("checkOnSubmit"=&#62;true,"closeOnEscape"=&#62;true,"closeAfterEdit"=&#62;true,"reloadAfterSubmit"=&#62;true));<br />$grid-&#62;setNavOptions(&#39;view&#39;,array("closeOnEscape"=&#62;true));<br />// Enjoy<br />$subtable = $subtable."_t";<br />$pager = $subtable."_p";<br />$grid-&#62;renderGrid($subtable,$pager, true, null, array(&#38;$rowid), true,true);<br />$conn = null;<br />?&#62;</p>
</p>
<p>database:</p>
<p>table: clientes</p>
<p>&#160;&#160; id_cliente, nombre, cif, direccion, cp, poblacion, provincia, email, telefono</p>
<p>table: avisos</p>
<p>&#160;&#160; id_aviso, id_cliente, fecha, descripcion</p>
]]></description>
        	        	<pubDate>Fri, 15 Jan 2010 17:37:45 +0200</pubDate>
        </item>
</channel>
</rss>