<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Opening branches by clicking rows in a Tree control in Flex</title>
	<link>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/</link>
	<description>A bunch of examples for Adobe Flex and ActionScript</description>
	<pubDate>Thu, 08 Jan 2009 17:13:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: Sam</title>
		<link>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-17614</link>
		<author>Sam</author>
		<pubDate>Wed, 07 Jan 2009 12:13:41 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-17614</guid>
		<description>Hi,

Nice example. Can you explain how to display only the nodes we want ?

For example, in your XML, you have "folder" nodes and "item" nodes, and I would like to only show "folder" nodes.

Is it possible ?

Thanks,

Sam</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Nice example. Can you explain how to display only the nodes we want ?</p>
<p>For example, in your XML, you have &#8220;folder&#8221; nodes and &#8220;item&#8221; nodes, and I would like to only show &#8220;folder&#8221; nodes.</p>
<p>Is it possible ?</p>
<p>Thanks,</p>
<p>Sam</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vijay Mareddy</title>
		<link>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-17137</link>
		<author>Vijay Mareddy</author>
		<pubDate>Tue, 02 Dec 2008 15:30:17 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-17137</guid>
		<description>For ADG u need to use the ADGGroupItemRenderer:
&lt;pre class="code"&gt;
public class MyAdvancedDataGridGroupItemRenderer extends AdvancedDataGridGroupItemRenderer {
    private var _listOwner:AdvancedDataGrid;
    private var _listData:AdvancedDataGridListData;

    public function MyAdvancedDataGridGroupItemRenderer(){
        super();
    }

    override public function set listData(value:BaseListData):void {
        super.listData = value;
        if (value) {            
            _listData = value as AdvancedDataGridListData;
            _listOwner = value.owner as AdvancedDataGrid;

            label.addEventListener(MouseEvent.MOUSE_OVER,
                function(event:MouseEvent):void {
                    _listOwner.contextMenu = myContextMenu();
                    event.stopImmediatePropagation();                        
                });

            label.addEventListener(MouseEvent.MOUSE_OUT,
                function(event:MouseEvent):void {
                    _listOwner.contextMenu = null;
                    event.stopImmediatePropagation();
                });

            addEventListener( MouseEvent.CLICK, 
                function(event:MouseEvent):void {
                    _listOwner.expandChildrenOf(_listData.item, !_listData.open);
                    event.stopImmediatePropagation();
                });
        }
    }

    private function myContextMenu():ContextMenu {
        var contextMenu:ContextMenu = new ContextMenu(); 
        contextMenu.hideBuiltInItems();

        var expandCollapseItem:ContextMenuItem = new ContextMenuItem(&#34;Expand/Collapse Item&#34;,false,true,true); 
        expandCollapseItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, 
            function(event:ContextMenuEvent):void {                                
                _listOwner.expandItem( _listData.item, !_listData.open, false, false,null);
                event.stopImmediatePropagation();
            });
        contextMenu.customItems.push(expandCollapseItem);

        var expandCollapseChildrenOf:ContextMenuItem = new ContextMenuItem(&#34;Expand/Collapse Children Of&#34;,false,true,true); 
        expandCollapseChildrenOf.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, 
            function(event:ContextMenuEvent):void {                    
                _listOwner.expandChildrenOf(_listData.item, !_listData.open);
                event.stopImmediatePropagation();
            });
        contextMenu.customItems.push(expandCollapseChildrenOf);
        /** 
         *     collapseAll/expandAll  is causing
         *     Error #1502: A script has executed for 
         *     longer than the default timeout period of 15 seconds.
         */
        //            var collapseAllMenuItem:ContextMenuItem = new ContextMenuItem(&#34;Collapse All Groups&#34;,true,true,true); 
        //            collapseAllMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, 
        //                function(event:ContextMenuEvent):void {
        //                    _listOwner.collapseAll();
        //                });
        //            contextMenu.customItems.push(collapseAllMenuItem);
        //            
        //            var expandAllMenuItem:ContextMenuItem = new ContextMenuItem(&#34;Expand All Groups&#34;,false,true,true);
        //            expandAllMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, 
        //                function(event:ContextMenuEvent):void {
        //                    _listOwner.expandAll();
        //                });
        //            contextMenu.customItems.push(expandAllMenuItem);

        return contextMenu;
    }
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>For ADG u need to use the ADGGroupItemRenderer:</p>
<pre class="code">
public class MyAdvancedDataGridGroupItemRenderer extends AdvancedDataGridGroupItemRenderer {
    private var _listOwner:AdvancedDataGrid;
    private var _listData:AdvancedDataGridListData;

    public function MyAdvancedDataGridGroupItemRenderer(){
        super();
    }

    override public function set listData(value:BaseListData):void {
        super.listData = value;
        if (value) {
            _listData = value as AdvancedDataGridListData;
            _listOwner = value.owner as AdvancedDataGrid;

            label.addEventListener(MouseEvent.MOUSE_OVER,
                function(event:MouseEvent):void {
                    _listOwner.contextMenu = myContextMenu();
                    event.stopImmediatePropagation();
                });

            label.addEventListener(MouseEvent.MOUSE_OUT,
                function(event:MouseEvent):void {
                    _listOwner.contextMenu = null;
                    event.stopImmediatePropagation();
                });

            addEventListener( MouseEvent.CLICK,
                function(event:MouseEvent):void {
                    _listOwner.expandChildrenOf(_listData.item, !_listData.open);
                    event.stopImmediatePropagation();
                });
        }
    }

    private function myContextMenu():ContextMenu {
        var contextMenu:ContextMenu = new ContextMenu();
        contextMenu.hideBuiltInItems();

        var expandCollapseItem:ContextMenuItem = new ContextMenuItem(&quot;Expand/Collapse Item&quot;,false,true,true);
        expandCollapseItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
            function(event:ContextMenuEvent):void {
                _listOwner.expandItem( _listData.item, !_listData.open, false, false,null);
                event.stopImmediatePropagation();
            });
        contextMenu.customItems.push(expandCollapseItem);

        var expandCollapseChildrenOf:ContextMenuItem = new ContextMenuItem(&quot;Expand/Collapse Children Of&quot;,false,true,true);
        expandCollapseChildrenOf.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
            function(event:ContextMenuEvent):void {
                _listOwner.expandChildrenOf(_listData.item, !_listData.open);
                event.stopImmediatePropagation();
            });
        contextMenu.customItems.push(expandCollapseChildrenOf);
        /**
         *     collapseAll/expandAll  is causing
         *     Error #1502: A script has executed for
         *     longer than the default timeout period of 15 seconds.
         */
        //            var collapseAllMenuItem:ContextMenuItem = new ContextMenuItem(&quot;Collapse All Groups&quot;,true,true,true);
        //            collapseAllMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
        //                function(event:ContextMenuEvent):void {
        //                    _listOwner.collapseAll();
        //                });
        //            contextMenu.customItems.push(collapseAllMenuItem);
        //
        //            var expandAllMenuItem:ContextMenuItem = new ContextMenuItem(&quot;Expand All Groups&quot;,false,true,true);
        //            expandAllMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
        //                function(event:ContextMenuEvent):void {
        //                    _listOwner.expandAll();
        //                });
        //            contextMenu.customItems.push(expandAllMenuItem);

        return contextMenu;
    }
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Senthil</title>
		<link>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-16460</link>
		<author>Senthil</author>
		<pubDate>Wed, 29 Oct 2008 13:04:50 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-16460</guid>
		<description>How to get the exact value from a itemRollover event when using an advanced datagrid</description>
		<content:encoded><![CDATA[<p>How to get the exact value from a itemRollover event when using an advanced datagrid</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DjKermit</title>
		<link>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-16357</link>
		<author>DjKermit</author>
		<pubDate>Wed, 22 Oct 2008 14:02:57 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-16357</guid>
		<description>About that close/open event dispatching, look at fourth parameter of expandItem method (dispatchEvent:Boolean = false). Set it to true and it will work just fine.</description>
		<content:encoded><![CDATA[<p>About that close/open event dispatching, look at fourth parameter of expandItem method (dispatchEvent:Boolean = false). Set it to true and it will work just fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven Walter</title>
		<link>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-15867</link>
		<author>Steven Walter</author>
		<pubDate>Fri, 26 Sep 2008 14:58:57 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-15867</guid>
		<description>Is there a way to get the actual item from a itemRollover event when using an advanced datagrid that is grouped from a flat arraycollection? With the original datagrid you could simply get the item using this method on the event:

event.currentTarget.dataProvider.getItemAt(event.rowIndex))</description>
		<content:encoded><![CDATA[<p>Is there a way to get the actual item from a itemRollover event when using an advanced datagrid that is grouped from a flat arraycollection? With the original datagrid you could simply get the item using this method on the event:</p>
<p>event.currentTarget.dataProvider.getItemAt(event.rowIndex))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee Probert</title>
		<link>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-15512</link>
		<author>Lee Probert</author>
		<pubDate>Fri, 12 Sep 2008 15:23:22 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-15512</guid>
		<description>Just to confirm ... with the AdvancedDataGrid not checking if the clicked item is a branch doesn't seem to matter. The only thing that confused me is the AdvancedDataGridItemSelectEvent in FB3 that the compiler doesn't like ... you need to use a standard ListEvent ... ho-hum! Also, while I'm at it ... if you're wondering how to assign different Item renderers for different branches look in the Flex help at the &#60;mx:rendererProviders&#62; tag ... this was very handy!</description>
		<content:encoded><![CDATA[<p>Just to confirm &#8230; with the AdvancedDataGrid not checking if the clicked item is a branch doesn&#8217;t seem to matter. The only thing that confused me is the AdvancedDataGridItemSelectEvent in FB3 that the compiler doesn&#8217;t like &#8230; you need to use a standard ListEvent &#8230; ho-hum! Also, while I&#8217;m at it &#8230; if you&#8217;re wondering how to assign different Item renderers for different branches look in the Flex help at the &lt;mx:rendererProviders&gt; tag &#8230; this was very handy!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GT</title>
		<link>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-15380</link>
		<author>GT</author>
		<pubDate>Mon, 08 Sep 2008 10:05:59 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-15380</guid>
		<description>Hi all.

For those who want to apply the same logic to an ADG, here's what I did (I'm an amateur, so be gentle if the coding turns out to contain woeful inefficiency)...
&lt;pre class="code"&gt;
private function adg_itemClick(evt:ListEvent):void {
    var item:Object = AdvancedDataGrid(evt.currentTarget).selectedItem;
    totList.expandItem(item, !totList.isItemOpen(item), true);
}
&lt;/pre&gt;

It worked perfectly. I got rid of the if test because I couldn't find the adg crollary to the dataDescriptor.isBranch bizzo. ('Bizzo' is an Australian technical term, meaning 'something I dont really understand'... I understand if you aren't familiar with it)

'totList' is the adg to which this function is applied as an itemClick.

As usual, flexexamples has given me something that solves a problem - with my role being to find out how to bash the example to fit my project.

Cheerio


GT
France

PS sorry for not uttingthe code in acode frame - I can't see how to do that.</description>
		<content:encoded><![CDATA[<p>Hi all.</p>
<p>For those who want to apply the same logic to an ADG, here&#8217;s what I did (I&#8217;m an amateur, so be gentle if the coding turns out to contain woeful inefficiency)&#8230;</p>
<pre class="code">
private function adg_itemClick(evt:ListEvent):void {
    var item:Object = AdvancedDataGrid(evt.currentTarget).selectedItem;
    totList.expandItem(item, !totList.isItemOpen(item), true);
}
</pre>
<p>It worked perfectly. I got rid of the if test because I couldn&#8217;t find the adg crollary to the dataDescriptor.isBranch bizzo. (&#8217;Bizzo&#8217; is an Australian technical term, meaning &#8217;something I dont really understand&#8217;&#8230; I understand if you aren&#8217;t familiar with it)</p>
<p>&#8216;totList&#8217; is the adg to which this function is applied as an itemClick.</p>
<p>As usual, flexexamples has given me something that solves a problem - with my role being to find out how to bash the example to fit my project.</p>
<p>Cheerio</p>
<p>GT<br />
France</p>
<p>PS sorry for not uttingthe code in acode frame - I can&#8217;t see how to do that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-14624</link>
		<author>John</author>
		<pubDate>Mon, 11 Aug 2008 16:25:04 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-14624</guid>
		<description>I'd like to see an example of this with AdvancedDataGrid as well!</description>
		<content:encoded><![CDATA[<p>I&#8217;d like to see an example of this with AdvancedDataGrid as well!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Maurer</title>
		<link>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-14426</link>
		<author>Andrew Maurer</author>
		<pubDate>Fri, 01 Aug 2008 02:05:26 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-14426</guid>
		<description>Thanks Peter, Great stuff!</description>
		<content:encoded><![CDATA[<p>Thanks Peter, Great stuff!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gerry</title>
		<link>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-14366</link>
		<author>Gerry</author>
		<pubDate>Sun, 27 Jul 2008 08:38:16 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/04/05/opening-branches-by-clicking-rows-in-a-tree-control-in-flex/#comment-14366</guid>
		<description>Great work!

Could you please tell me how to handle the item_click stuff in reference to an ADVANCEDDATAGRID.

Many thanks in advance.

Gerry</description>
		<content:encoded><![CDATA[<p>Great work!</p>
<p>Could you please tell me how to handle the item_click stuff in reference to an ADVANCEDDATAGRID.</p>
<p>Many thanks in advance.</p>
<p>Gerry</p>
]]></content:encoded>
	</item>
</channel>
</rss>
