<?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: expand only the root node of the tree</title>
	<link>http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree</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/expand-only-the-root-node-of-the-tree/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>kobruleht on expand only the root node of the tree</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23073</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23073</guid>
        	        	<description><![CDATA[<p>The other possibility is to provide data for selected leaf and&#160;setting expanded and loaded properties to true for this path. In this case proper tree is loaded using single server request. Ides from /blog/?page_id=393/treegrid/jqgrid-4-adjacency-model-expanded_field-problem/&#160;can used.</p>
</p>
<p>Andrus.</p>
]]></description>
        	        	<pubDate>Sun, 08 May 2011 17:33:52 +0300</pubDate>
        </item>
        <item>
        	<title>kobruleht on expand only the root node of the tree</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23072</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23072</guid>
        	        	<description><![CDATA[<p>I also notices that even without&#160;<span style="font-family: Consolas; color: #006400; font-size: x-small;"><span style="font-family: Consolas; color: #006400; font-size: x-small;"><span style="font-family: Consolas; color: #006400; font-size: x-small;"></span></span></span></p>
<p>setSelection</p>
</p>
<p>this method causes ugly&#160; tree flashing: tree disappears first and appear afterwards incrementally. How to remove this flash ? Should we hide tree and show it only after it is fully constructed or other idea ?</p>
<p>Andrus.</p>
]]></description>
        	        	<pubDate>Sun, 08 May 2011 17:07:50 +0300</pubDate>
        </item>
        <item>
        	<title>kobruleht on expand only the root node of the tree</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23071</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23071</guid>
        	        	<description><![CDATA[<p>Application loads new page on every node (leaf or non-leaf click ) using</p>
</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; onSelectRow: function (rowid) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var treedata = grid.jqGrid(&#39;getRowData&#39;, rowid);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; window.location = &#39;&#60;%= ResolveUrl("~/")%&#62;&#39; + treedata.url;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>
</p>
<p>setSelection in your code probably causes this event. This event causes your code call which causes this event again etc. Treegrid flashes forever in this case. How to fix ?</p>
<p>Andrus.</p>
]]></description>
        	        	<pubDate>Sun, 08 May 2011 16:48:12 +0300</pubDate>
        </item>
        <item>
        	<title>lathspell on expand only the root node of the tree</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23068</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23068</guid>
        	        	<description><![CDATA[<p>Hm.. the approach with .click() does not seem to be reliable when using a dynamically loaded tree in opposite to one where the whole data is send immediately. So I&#39;ve come up with a better solution. Still I don&#39;t understand why the setTimeout() function seems absolutely neccessary to make it work.</p>
</p>
<p>As only the nodes of the top level and then the explicitly requested are available, the "path" from top to the requested node has to be defined in the Javascript page e.g. by PHP:</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; autoClicked = [5, 7, 8]; // global "todo" list</p>
<p>then a gridLoaded function has to be defined for the grid. When first loaded this function triggers the expansion of node 5. After that node is rendered the function is called again. Now it opens id=5. After that id=8. Then the queue is empty and the page has the complette tree down to id=8 open!</p>
<p>&#160;&#160;&#160; jQuery(document).ready(function() {<br />&#160; &#160; &#160;&#160; var mygrid = jQuery("#treegrid2").jqGrid({</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ....</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; gridComplete: function() {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; // * This function is called everytime a node is expanded and not<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //&#160;&#160; only once after the page is loaded. Therefore only one node<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //&#160;&#160; at a time can be expanded and we need a global "todo list".<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; // * getRowData() returns the data as set by the server without some<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //&#160;&#160; internally added attributes which expandNode() relies on.<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //&#160;&#160; Therefore getGridParam() has to be used.<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; // * When using a dynamical loaded tree the position of a specific<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //&#160;&#160; id in the data array cannot easily be precalucated by the server<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //&#160;&#160; therefore we search for the id in a loop every time.<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; setTimeout(function() {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var id = autoClicked.shift();</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var mygrid = jQuery(&#39;#treegrid2&#39;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var rData = mygrid.getGridParam(&#39;data&#39;);</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; var data = null;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; for (var i=0; i &#60; rData.length; i++) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (id == rData[i].id) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; data = rData[i];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#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; } <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mygrid.expandRow(data);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mygrid.expandNode(data);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mygrid.setSelection(id);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }, 0); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</p>
<p>}</p></p>
]]></description>
        	        	<pubDate>Sun, 08 May 2011 14:31:36 +0300</pubDate>
        </item>
        <item>
        	<title>lathspell on expand only the root node of the tree</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23065</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23065</guid>
        	        	<description><![CDATA[<p>Coincidently I spend the last night also wondering how to have a single tree expanded right after loading the page.</p>
<p>My solution was like this. It also needs this magical setTimeoutFunction(... , 0) which I cannot quite make sense of but then uses</p>
<p>the .click() function to avoid trying to figure out which jqGrid API functions are neccessary:</p>
</p>
<p>gridComplete: function() {</p>
<p>&#160;&#160;&#160;&#160;&#160; setTimeout(function(){<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; autoClicked = [&#60;?php echo $autoClicked ?&#62;];<br />&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery.each(autoClicked, function(index, value) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery(&#39;#&#39; + value + &#39; td div&#39;).click(); &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }, 0);</p>
<p>}</p>
</p>
<p>The autoClicked variable gets a list of nodes e.g. [3, 5, 8] that should be opened ("clicked as by the user") in exactly this order.</p>
<p>The page load then produces 4 AJAX requests, the first for the root and then the 3 which I faked.</p>
<p>Not using the jqGrid API means that you have to rely on this "#id td div" selector not to change though.</p>
</p>
<p>But can anybody explain the setTimeout() with the 0 seconds parameter, please? It just does not work without even if the loadComplete or gridComplete hooks should have the rest of the grid loaded at that time.</p>
]]></description>
        	        	<pubDate>Sun, 08 May 2011 13:33:33 +0300</pubDate>
        </item>
        <item>
        	<title>lathspell on expand only the root node of the tree</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23064</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23064</guid>
        	        	<description><![CDATA[<p>$emplist should be replaced by mylist, I think.</p>
]]></description>
        	        	<pubDate>Sun, 08 May 2011 13:25:46 +0300</pubDate>
        </item>
        <item>
        	<title>kobruleht on expand only the root node of the tree</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23063</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p23063</guid>
        	        	<description><![CDATA[<p>I tried but no&#160; is rows are expanded.</p>
<p>How $empList is defined ?</p>
<p>Andrus.</p>
]]></description>
        	        	<pubDate>Sun, 08 May 2011 12:40:52 +0300</pubDate>
        </item>
        <item>
        	<title>nate on expand only the root node of the tree</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p20471</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p20471</guid>
        	        	<description><![CDATA[<blockquote>
<p>terryg said:What is the correct way to code the root node of a JSON, AJAX-loaded tree to render with only the root node expanded? I tried various combinations of expandRow(), expandNode(), and click(), but I couldn&#39;t get any of them to work. Most of my attempts have been inside the gridComplete() handler.</p>
</blockquote>
<hr />
<p>This method worked for me. I hope it helps: (not sure why the expandRow and expandNode only work within the setTimeout function)</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit4832' value='Select Code' data-codeid='sfcode4832' /></p>
<div class='sfcode' id='sfcode4832'>
<p>var mygrid = jQuery(&#39;#grid&#39;).jqGrid({</p>
<p>...</p>
<p>gridComplete: function() {</p>
<p>&#160;&#160;var rData = mygrid.jqGrid(&#39;getGridParam&#39;, &#39;data&#39;);</p>
<p>&#160;&#160;if(rData[0]){</p>
<p>&#160;&#160; &#160;setTimeout(function(){</p>
<p>&#160;&#160; &#160; &#160;$empList.expandRow(rData[0]);</p>
<p>&#160;&#160; &#160; &#160;$empList.expandNode(rData[0]);</p>
<p>&#160;&#160; &#160;}, 0);</p>
<p>&#160;&#160;}</p>
<p>},</p>
</div>
]]></description>
        	        	<pubDate>Mon, 25 Oct 2010 22:11:22 +0300</pubDate>
        </item>
        <item>
        	<title>terryg on expand only the root node of the tree</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p20332</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/expand-only-the-root-node-of-the-tree#p20332</guid>
        	        	<description><![CDATA[<p>What is the correct way to code the root node of a JSON, AJAX-loaded tree to render with only the root node expanded? I tried various combinations of expandRow(), expandNode(), and click(), but I couldn&#39;t get any of them to work. Most of my attempts have been inside the gridComplete() handler.</p>
]]></description>
        	        	<pubDate>Fri, 15 Oct 2010 20:54:21 +0300</pubDate>
        </item>
</channel>
</rss>