<?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:  Adjacency List Model problem</title>
	<link>http://www.trirand.com/blog/?page_id=393/treegrid/adjacency-list-model-problem-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/treegrid/adjacency-list-model-problem-1/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>dana on  Adjacency List Model problem</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/adjacency-list-model-problem-1#p7785</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/adjacency-list-model-problem-1#p7785</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>I am using treeGrid as grid, Adjacency List Model.</p>
<p>jqGrid 3.4.4</p>
<p>I get this Javascript error message: <br />&#160; error: &#39;0&#39; is null or not an object</p>
<p>I read your Trouble-Shooting :<br />&#160; "&#39;ts.p.colModel[...].align&#39; is null or not an object<br />This one means you are sending too many columns of data from the server. <br />If you send too few, then the grid will appear but one or<br />&#160;more columns may be missing with data showing up in the wrong column;<br />&#160; if you have more hidden fields then missing columns,<br />&#160;&#160; you might not see this effect until you edit a row and<br />&#160;&#160;&#160; see that one or more fields are not showing up there."</p>
<p>What missing or worng&#160; in my code?</p>
<p>My code:</p>
<p>... example_f1.php<br />&#60;?php<br />class testJqGrid<br />{<br />&#160;&#160;&#160; <br />function __construct()<br />&#160;&#160; {<br />&#160;&#160;&#160;&#160; $this-&#62;viewHtml();<br />&#160;&#160; }</p>
<p>function viewHtml()<br />&#160;&#160; {<br />&#160;&#160; &#160;?&#62;<br />&#160;&#160; &#160;&#60;html&#62;<br />&#60;head&#62;<br />&#60;title&#62;jqGrid Demo&#60;/title&#62;<br />&#60;link rel="stylesheet" type="text/css" media="screen" href="../themes/sand/grid.css" /&#62;<br />&#60;link rel="stylesheet" type="text/css" media="screen" href="../themes/jqModal.css" /&#62;<br />&#60;script src="../jquery.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script src="../jquery.jqGrid.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script src="../js/jqModal.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script src="../js/jqDnR.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script src="../js/grid.treegrid.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script src="../js/jquery.jqTree.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#60;script type="text/javascript"&#62;<br />gridimgpath = &#39;../themes/sand/images&#39;;<br />jQuery(document).ready(function(){<br />jQuery("#navgridx").jqGrid({</p>
<p>&#160;&#160; &#160;<a href="&#39;server_f1.php&#39;" target="_blank">url:&#39;server_f1.php&#39;</a>,<br />&#160;datatype: "json",<br />&#160;mtype: "POST",<br />&#160;&#160;&#160; colNames:[&#39;id&#39;,&#39;levelx&#39;,&#39;range&#39;, &#39;desc&#39;, &#39;parent_id&#39;,&#39;is_leaf&#39;],<br />&#160;&#160; &#160;colModel:[<br />&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;id&#39;,index:&#39;id&#39;, width:1,hidden:true,key:true},<br />&#160; &#160;&#160;{name:&#39;levelx&#39;,index:&#39;levelx&#39;, width:30, align:"left",editable:true,editoptions:{size:30}},<br />&#160;&#160; &#160;&#160;{name:&#39;range&#39;,index:&#39;range&#39;, width:30,editable:true,editoptions:{size:30}},<br />&#160;&#160; &#160;&#160;{name:&#39;desc&#39;,index:&#39;desc&#39;, width:50,editable:true,editoptions:{size:50}},<br />&#160;&#160; &#160;&#160;{name:&#39;parent_id&#39;,index:&#39;parent_id&#39;, width:40,align:"right",editable:true,editoptions:{size:40}},<br />&#160;&#160;&#160; &#160;{name:&#39;is_leaf&#39;,index:&#39;is_leaf&#39;, width:40,align:"right",editable:true,editoptions:{size:40}}<br />&#160;&#160;&#160; &#160;],&#160;<br />&#160;&#160;&#160; imgpath: gridimgpath,<br />&#160;&#160; &#160;pager: jQuery(&#39;#pagernav&#39;),<br />&#160;&#160; &#160;width:&#160; "800",<br />&#160;height: "auto",<br />&#160;treeGrid: true,<br />&#160;treeGridModel : &#39;adjacency&#39;,<br />&#160;ExpandColumn : &#39;levelx&#39;,<br />&#160;tree_root_level :2,<br />&#160;treeReader : { level_field: "levelx",<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; parent_id_field: "parent_id",<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; leaf_field: "is_leaf",<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; expanded_field: "expanded" },<br />&#160;&#160;&#160; caption:"My Tree Navigator Example",<br />&#160;&#160;&#160; editurl:&#39;someurl_f1.php&#39;<br />&#160;&#160;&#160; }).navGrid("#pagernav",{find:true,edit:true,add:false,del:false,position:"left"},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {reloadAfterSubmit:false}<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; );<br />}); <br />&#60;/script&#62;<br />&#60;/head&#62; <br />&#60;body&#62;</p>
<p>&#60;table id="navgridx" class="scroll" cellpadding="0" cellspacing="0"&#62;&#60;/table&#62;<br />&#60;div id="pagernav" class="scroll" style="text-align:center;"&#62;&#60;/div&#62;</p>
<p>&#60;/body&#62; <br />&#60;/html&#62;<br />&#60;?</p>
<p>&#160;&#160; }<br />}</p>
<p>$testJqGrid = new testJqGrid();<br />?&#62;</p>
<p>.....&#160; server_f1.php<br />&#60;?php<br />class testJqGridArr<br />{</p>
<p>&#160;&#160;&#160; <br />function __construct()<br />{<br />$this-&#62;viewHtmlArr();<br />}</p>
<p>function viewHtmlArr()<br />&#160;&#160; {<br />include("JSON.php");<br />$json = new Services_JSON();</p>
<p>$count=9;</p>
<p>$page = 1;&#160;&#160;&#160;&#160;&#160;&#160; //$_REQUEST[&#39;page&#39;]; // get the requested page<br />$limit = 10;&#160;&#160;&#160;&#160; //$_REQUEST[&#39;rows&#39;]; // get how many rows we want to have into the grid<br />$sidx = 1;&#160;&#160;&#160;&#160;&#160;&#160; //$_REQUEST[&#39;sidx&#39;]; // get index row - i.e. user click to sort<br />$sord = &#39;asc&#39;;&#160;&#160; //$_REQUEST[&#39;sord&#39;]; // get the direction<br />$debug = $_REQUEST[&#39;debug&#39;];</p>
<p>if(!$sidx) $sidx =1;</p>
<p>// array instead of use DB table</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($debug ) echo $stat.&#39;&#60;br&#62;&#39;;<br />&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $myArr = array(<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;0&#39;=&#62; array(&#39;ID&#39;=&#62;&#39;1&#39;,&#39;LEVELX&#39;=&#62;1,&#39;RANGE&#39;=&#62;&#39;0-90&#39;,&#39;DESC&#39;=&#62;&#39;ROOT&#39;,&#39;PARENT_ID&#39;=&#62;&#39;&#39;,&#39;IS_LEAF&#39;=&#62;&#39;false&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;1&#39; =&#62; array(&#39;ID&#39;=&#62;&#39;2&#39;,&#39;LEVELX&#39;=&#62;2,&#39;RANGE&#39;=&#62;&#39;0-10&#39;,&#39;DESC&#39;=&#62;&#39;GRP 1&#39;,&#39;PARENT_ID&#39;=&#62;&#39;1&#39;,&#39;IS_LEAF&#39;=&#62;&#39;false&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;2&#39; =&#62; array(&#39;ID&#39;=&#62;&#39;3&#39;,&#39;LEVELX&#39;=&#62;3,&#39;RANGE&#39;=&#62;&#39;1-5&#39; ,&#39;DESC&#39;=&#62;&#39;GRP 1A&#39;,&#39;PARENT_ID&#39;=&#62;&#39;2&#39;,&#39;IS_LEAF&#39;=&#62;&#39;true&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;3&#39; =&#62; array(&#39;ID&#39;=&#62;&#39;4&#39;,&#39;LEVELX&#39;=&#62;3,&#39;RANGE&#39;=&#62;&#39;6-10&#39;,&#39;DESC&#39;=&#62;&#39;GRP 1B&#39;,&#39;PARENT_ID&#39;=&#62;&#39;2&#39;,&#39;IS_LEAF&#39;=&#62;&#39;true&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;4&#39; =&#62; array(&#39;ID&#39;=&#62;&#39;5&#39;,&#39;LEVELX&#39;=&#62;2,&#39;RANGE&#39;=&#62;&#39;11-30&#39;,&#39;DESC&#39;=&#62;&#39;GRP 2&#39;,&#39;PARENT_ID&#39;=&#62;&#39;1&#39;,&#39;IS_LEAF&#39;=&#62;&#39;false&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;5&#39; =&#62; array(&#39;ID&#39;=&#62;&#39;6&#39;,&#39;LEVELX&#39;=&#62;3,&#39;RANGE&#39;=&#62;&#39;11-15&#39;,&#39;DESC&#39;=&#62;&#39;GRP 2A&#39;,&#39;PARENT_ID&#39;=&#62;&#39;5&#39;,&#39;IS_LEAF&#39;=&#62;&#39;true&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;6&#39; =&#62; array(&#39;ID&#39;=&#62;&#39;7&#39;,&#39;LEVELX&#39;=&#62;3,&#39;RANGE&#39;=&#62;&#39;15-20&#39;,&#39;DESC&#39;=&#62;&#39;GRP 2B&#39;,&#39;PARENT_ID&#39;=&#62;&#39;5&#39;,&#39;IS_LEAF&#39;=&#62;&#39;true&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;7&#39; =&#62; array(&#39;ID&#39;=&#62;&#39;8&#39;,&#39;LEVELX&#39;=&#62;3,&#39;RANGE&#39;=&#62;&#39;21-25&#39;,&#39;DESC&#39;=&#62;&#39;GRP 2C&#39;,&#39;PARENT_ID&#39;=&#62;&#39;5&#39;,&#39;IS_LEAF&#39;=&#62;&#39;true&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#39;8&#39; =&#62; array(&#39;ID&#39;=&#62;&#39;9&#39;,&#39;LEVELX&#39;=&#62;3,&#39;RANGE&#39;=&#62;&#39;26-30&#39;,&#39;DESC&#39;=&#62;&#39;GRP 2D&#39;,&#39;PARENT_ID&#39;=&#62;&#39;5&#39;,&#39;IS_LEAF&#39;=&#62;&#39;true&#39;) <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; );&#160;&#160;&#160;&#160;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; $responce-&#62;page = 1;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $responce-&#62;total = 9;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $responce-&#62;records = $count;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $i=0;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; foreach($myArr as $key =&#62; $row)<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $responce-&#62;rows[$i][&#39;id&#39;]=$row[&#39;ID&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $responce-&#62;rows[$i][&#39;cell&#39;]=array($row[&#39;ID&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $row[&#39;LEVELX&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $row[&#39;RANGE&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $row[&#39;DESC&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $row[&#39;PARENT_ID&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $row[&#39;IS_LEAF&#39;]<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; );<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $i++;<br />&#160;&#160;}&#160;&#160;&#160;&#160;&#160;&#160;&#160;</p>
<p>&#160;&#160;echo $json-&#62;encode($responce); // coment if php 5<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($debug )<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; { <br />&#160;&#160;&#160;&#160;&#160; echo &#39;&#60;br&#62;&#160; test&#39;;<br />&#160;&#160;&#160;&#160;&#160; print_r($responce);<br />&#160;&#160;&#160;&#160;&#160; echo &#39;&#60;br&#62;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; print_r($_REQUEST);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160; echo &#39;&#60;br&#62;&#39;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160; }<br />function Strip_x($value)<br />{<br />&#160;if(get_magic_quotes_gpc() != 0)<br />&#160; &#160;{<br />&#160;&#160;&#160; &#160;if(is_array($value))&#160; <br />&#160;&#160;&#160;if ( $this-&#62;array_is_associative($value) )<br />&#160;&#160;&#160;{<br />&#160;&#160;&#160;&#160;foreach( $value as $k=&#62;$v)<br />&#160;&#160;&#160;&#160;&#160;$tmp_val[$k] = stripslashes($v);<br />&#160;&#160;&#160;&#160;$value = $tmp_val; <br />&#160;&#160;&#160;}&#160;&#160;&#160;&#160;<br />&#160;&#160;&#160;else&#160; <br />&#160;&#160;&#160;&#160;for($j = 0; $j &#60; sizeof($value); $j++)<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;$value[$j] = stripslashes($value[$j]);<br />&#160;&#160;else<br />&#160;&#160;&#160;$value = stripslashes($value);<br />&#160;}<br />&#160;return $value;<br />}<br />function array_is_associative_x ($array)<br />{<br />&#160;&#160;&#160; if ( is_array($array) &#38;&#38; ! empty($array) )<br />&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; for ( $iterator = count($array) - 1; $iterator; $iterator-- )<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if ( ! array_key_exists($iterator, $array) ) { return true; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return ! array_key_exists(0, $array);<br />&#160;&#160;&#160; }<br />&#160;&#160;&#160; return false;<br />}</p>
<p>&#160;&#160; <br />}</p>
<p>$testJqGridArr = new testJqGridArr();<br />?&#62;</p>
<p>... someurl_f1.php<br />&#60;?php<br />?&#62;</p>
</p>
<p>thanks</p></p>
]]></description>
        	        	<pubDate>Mon, 13 Jul 2009 00:23:33 +0300</pubDate>
        </item>
</channel>
</rss>