<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Displaying the number of children in each branch of a Flex Tree control</title>
	<atom:link href="http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Sun, 12 Feb 2012 19:26:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: adrian</title>
		<link>http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/comment-page-1/#comment-4809</link>
		<dc:creator>adrian</dc:creator>
		<pubDate>Wed, 29 Jul 2009 08:28:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/#comment-4809</guid>
		<description>Do you know how to display only branches (folders) in Tree?</description>
		<content:encoded><![CDATA[<p>Do you know how to display only branches (folders) in Tree?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/comment-page-1/#comment-2268</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Mon, 19 Jan 2009 09:58:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/#comment-2268</guid>
		<description>Cool, it helps me a lot.
Thank you.</description>
		<content:encoded><![CDATA[<p>Cool, it helps me a lot.<br />
Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/comment-page-1/#comment-2267</link>
		<dc:creator>peterd</dc:creator>
		<pubDate>Mon, 07 Apr 2008 04:02:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/#comment-2267</guid>
		<description>Dusan,

Yeah, this blog isn&#039;t very friendly for posting code. You&#039;d need to escape your &lt; as &lt; before posting.

As for your ComboBox question, set the &lt;code&gt;prompt&lt;/code&gt; property. For an example, see &lt;a href=&quot;http://blog.flexexamples.com/2007/09/25/creating-a-simple-label-function-on-a-flex-combobox-control/&quot; rel=&quot;nofollow&quot;&gt;&lt;u&gt;&quot;Creating a simple label function on a Flex ComboBox control&quot;&lt;/u&gt;&lt;/a&gt;.

Peter</description>
		<content:encoded><![CDATA[<p>Dusan,</p>
<p>Yeah, this blog isn&#8217;t very friendly for posting code. You&#8217;d need to escape your &lt; as &amp;lt; before posting.</p>
<p>As for your ComboBox question, set the <code>prompt</code> property. For an example, see <a href="http://blog.flexexamples.com/2007/09/25/creating-a-simple-label-function-on-a-flex-combobox-control/" rel="nofollow"><u>&#8220;Creating a simple label function on a Flex ComboBox control&#8221;</u></a>.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dusan</title>
		<link>http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/comment-page-1/#comment-2256</link>
		<dc:creator>Dusan</dc:creator>
		<pubDate>Sun, 06 Apr 2008 23:41:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/#comment-2256</guid>
		<description>it seems that i cannot post xml code, probly i cose i dont know how, but nevermind, this is what i  used in tree xml
 node label=&quot;empty folder&quot; isBranch=&quot;true&quot;</description>
		<content:encoded><![CDATA[<p>it seems that i cannot post xml code, probly i cose i dont know how, but nevermind, this is what i  used in tree xml<br />
 node label=&#8221;empty folder&#8221; isBranch=&#8221;true&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dusan</title>
		<link>http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/comment-page-1/#comment-2255</link>
		<dc:creator>Dusan</dc:creator>
		<pubDate>Sun, 06 Apr 2008 23:37:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/#comment-2255</guid>
		<description>my tree isnt in the post above, dont know what happened lol</description>
		<content:encoded><![CDATA[<p>my tree isnt in the post above, dont know what happened lol</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dusan</title>
		<link>http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/comment-page-1/#comment-2257</link>
		<dc:creator>Dusan</dc:creator>
		<pubDate>Sun, 06 Apr 2008 23:36:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/#comment-2257</guid>
		<description>First, thanks for your time, and thanks for the help, you helped me a lot. Now:

i did some work and find out some things, and realised what u meant.I used &quot;isBranch=&quot;true&quot;&quot; in tree XML and it seems that that did the trick. I got this XML now:














my tree looks like this:


i used your function tree_labelFunc:
private function tree_labelFunc(item:XML):String {
                var label:String = item.@label;
                if (tree1.dataDescriptor.hasChildren(item)) {selectednode.text = label;
                	comboBoxFolder[j] = label;
                    label += &quot; (&quot; + tree1.dataDescriptor.getChildren(item).length + &quot;)&quot;;
                }
                return label;
            }
Tree is now just like i wanted. Only one thing i need now, its about combobox, im using this:

private function comboBox_labelFunc(item:XML):String {return item.@label;}

this works fine since i dont have any leafs in root of the tree, and i wont have them.
now, the thing i need is, when i start application selected item in combobox is first item in combobox, in this case its &quot;news&quot;, how do i set that when application starts noone of the items are selected.

Dusan.</description>
		<content:encoded><![CDATA[<p>First, thanks for your time, and thanks for the help, you helped me a lot. Now:</p>
<p>i did some work and find out some things, and realised what u meant.I used &#8220;isBranch=&#8221;true&#8221;" in tree XML and it seems that that did the trick. I got this XML now:</p>
<p>my tree looks like this:</p>
<p>i used your function tree_labelFunc:<br />
private function tree_labelFunc(item:XML):String {<br />
                var label:String = item.@label;<br />
                if (tree1.dataDescriptor.hasChildren(item)) {selectednode.text = label;<br />
                	comboBoxFolder[j] = label;<br />
                    label += &#8221; (&#8221; + tree1.dataDescriptor.getChildren(item).length + &#8220;)&#8221;;<br />
                }<br />
                return label;<br />
            }<br />
Tree is now just like i wanted. Only one thing i need now, its about combobox, im using this:</p>
<p>private function comboBox_labelFunc(item:XML):String {return item.@label;}</p>
<p>this works fine since i dont have any leafs in root of the tree, and i wont have them.<br />
now, the thing i need is, when i start application selected item in combobox is first item in combobox, in this case its &#8220;news&#8221;, how do i set that when application starts noone of the items are selected.</p>
<p>Dusan.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/comment-page-1/#comment-2266</link>
		<dc:creator>peterd</dc:creator>
		<pubDate>Sat, 05 Apr 2008 01:20:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/#comment-2266</guid>
		<description>Dusan,

Sorry, I guess I&#039;m confused. It seems you&#039;re trying to display possibly nested data in a linear List. How would you know if a node is an empty branch or just a leaf node?
The &lt;code&gt;isBranch()&lt;/code&gt; method works on a Tree because Trees can have multiple levels with children, whereas a list is usually only for displaying flat data.

If you only want to display the &quot;i) four (4)&quot; and &quot;ii) three (2)&quot; branches, I think you&#039;d need to use the following E4X which grabs all branches with at least one child:
&lt;pre class=&quot;code&quot;&gt;
dataProvider=&quot;{treeDP..node.(children().length() != 0)}&quot;
&lt;/pre&gt;

Otherwise, how would your Flex application know if it was looking at an empty branch or a leaf node (unless you put some sort of flag in your XML nodes indicating whether something was a branch or leaf).

Peter</description>
		<content:encoded><![CDATA[<p>Dusan,</p>
<p>Sorry, I guess I&#8217;m confused. It seems you&#8217;re trying to display possibly nested data in a linear List. How would you know if a node is an empty branch or just a leaf node?<br />
The <code>isBranch()</code> method works on a Tree because Trees can have multiple levels with children, whereas a list is usually only for displaying flat data.</p>
<p>If you only want to display the &#8220;i) four (4)&#8221; and &#8220;ii) three (2)&#8221; branches, I think you&#8217;d need to use the following E4X which grabs all branches with at least one child:</p>
<pre class="code">
dataProvider="{treeDP..node.(children().length() != 0)}"
</pre>
<p>Otherwise, how would your Flex application know if it was looking at an empty branch or a leaf node (unless you put some sort of flag in your XML nodes indicating whether something was a branch or leaf).</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dusan</title>
		<link>http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/comment-page-1/#comment-2265</link>
		<dc:creator>Dusan</dc:creator>
		<pubDate>Fri, 04 Apr 2008 22:59:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/#comment-2265</guid>
		<description>uhh, i guess u dont understand me :(
when i put this i code i get both leafs and branches in combobox, i need only branches. I&#039;ve been trying to solve this whole day :(. i tried to make something with &quot;isBranch()&quot;, but with no success.</description>
		<content:encoded><![CDATA[<p>uhh, i guess u dont understand me :(<br />
when i put this i code i get both leafs and branches in combobox, i need only branches. I&#8217;ve been trying to solve this whole day :(. i tried to make something with &#8220;isBranch()&#8221;, but with no success.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/comment-page-1/#comment-2264</link>
		<dc:creator>peterd</dc:creator>
		<pubDate>Fri, 04 Apr 2008 22:48:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/#comment-2264</guid>
		<description>Dusan,

Something like this?
&lt;pre class=&quot;code&quot;&gt;
&lt;mx:ComboBox id=&quot;checkBox&quot;
        dataProvider=&quot;{treeDP..node}&quot;
        labelFunction=&quot;comboBox_labelFunc&quot; /&gt;
&lt;/pre&gt;

Peter</description>
		<content:encoded><![CDATA[<p>Dusan,</p>
<p>Something like this?</p>
<pre class="code">
&lt;mx:ComboBox id="checkBox"
        dataProvider="{treeDP..node}"
        labelFunction="comboBox_labelFunc" /&gt;
</pre>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dusan</title>
		<link>http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/comment-page-1/#comment-2263</link>
		<dc:creator>Dusan</dc:creator>
		<pubDate>Fri, 04 Apr 2008 21:33:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/01/11/displaying-the-number-of-children-in-each-branch-of-a-flex-tree-control/#comment-2263</guid>
		<description>dataProvider=&quot;{treeDP..node.(children().length() != 0)}&quot; , i guess tells that its using non-empty branches, what if i have empty branches and want to display them in combobox? The thing is that im downloading XML file ( which can be changed ) from server and im displaying it as tree. Now when tree is displayed i can add empty branches, and also add leafs in that branches. And i want to display them in combobox ( branches, not leafs :) )

ty a lot for help so far</description>
		<content:encoded><![CDATA[<p>dataProvider=&#8221;{treeDP..node.(children().length() != 0)}&#8221; , i guess tells that its using non-empty branches, what if i have empty branches and want to display them in combobox? The thing is that im downloading XML file ( which can be changed ) from server and im displaying it as tree. Now when tree is displayed i can add empty branches, and also add leafs in that branches. And i want to display them in combobox ( branches, not leafs :) )</p>
<p>ty a lot for help so far</p>
]]></content:encoded>
	</item>
</channel>
</rss>

