Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex: Add items to DropDownList using ItemRenderer
    primarykey
    data
    text
    <p>I have a XML structure like: </p> <pre><code>&lt;Main&gt; &lt;Category1&gt; &lt;Data Name="Data1"&gt; &lt;Item&gt; &lt;Name&gt;foo&lt;/Name&gt; &lt;Info&gt;bar&lt;/Info&gt; &lt;/Item&gt; &lt;Item&gt; &lt;Name&gt;baz&lt;/Name&gt; &lt;Info&gt;FOO&lt;/Info&gt; &lt;/Item&gt; &lt;/Data&gt; &lt;Data Name="Data2"&gt; &lt;/Data&gt; &lt;/Category1&gt; &lt;Category2&gt; &lt;/Category2&gt; &lt;/Main&gt; </code></pre> <p>I use a custom <strong>DropDownList</strong> to populate it using an ItemRendererFunction:</p> <pre><code>&lt;s:Label text="{data.attribute('Name')}" top="3" left="10" right="10" bottom="3" color="0xFF00FF" /&gt; </code></pre> <p>if it has an attribute 'Name', else a regular Label. </p> <p>Render function is : </p> <pre><code>public function renderNode(item:*):IFactory { if (item.attribute('Name') != null) return new ClassFactory(SpecialItemRenderer); else return new ClassFactory(RegularItemRenderer); } </code></pre> <p>However, I specify the XML in the form of a dataProvider, as dProv.child('Category1'), hence I only get the 2 <code>&lt;Data&gt;</code> nodes in the <code>renderNode()</code>. But I also want to populate the <code>&lt;Item&gt;</code> nodes at the same time. </p> <p>I've tried using a loop using a new itemRendererFunction <code>newFunc(item:*):void</code>: </p> <pre><code>var nodes:XMLNode = item.children(); while(nodes) { this.renderNode(nodes); nodes = nodes.nextSibling; } </code></pre> <p>but got a runtime error as the <code>newFunc()</code> wouldn't be returning anything. </p> <p>Then I made changes to the original <code>renderNode()</code> by creating a <code>mx:Label</code> item dynamically &amp; adding it to <code>this</code> via <code>this.addElement(newLabel)</code> but this wouldn't place the Label in the drop down list, but on top of the control. </p> <p>So I'd like to know is there any way I can add these Items/label dynamically while parsing the original XML Data?</p> <p>Regards,<br> Nisheeth Barthwal</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload