Note that there are some explanatory texts on larger screens.

plurals
  1. POAdobe Flex 4.5 Spark: Binding ItemRenderer Component to Parent
    primarykey
    data
    text
    <p>In Flex 3, it used to be possible to bind a component property within an itemRenderer via outerDocument. So for instance, if there was a image inside an itemRenderer that was only displayed on a given condition of the parent, something like this would work perfectly:</p> <pre><code>&lt;mx:itemRenderer&gt; &lt;mx:Component&gt; &lt;mx:Label text="{data}"/&gt; &lt;mx:Image id="img" visible="{outerDocument.ShowImage}" includeInLayout="{outerDocument.ShowImage}"/&gt; &lt;/mx:Component&gt; &lt;/mx:itemRenderer&gt; </code></pre> <p>where the outer document (not the list, but the mxml the list is in) contained something like</p> <pre><code>[Bindable] public function get ShowImage():void { return showImage; } public function set ShowImage(val:Boolean):void { showImage = val; } </code></pre> <p>I've tried to do the same thing in Flex 4.5 using Spark item renderers using parentDocument, but it doesn't seem to be aware to the binding. When I do this in Flex 4.5, the itemRenderer doesn't seem to be aware when the parentDocument ShowImage changes.</p> <p>Has anyone seen this issue and is able to offer a solution?</p> <p>EDIT: Add Spark Source As requested here is my spark source:</p> <p>MyItemRenderer.mxml</p> <pre><code>&lt;s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"&gt; &lt;s:Label id="myLabel" text="{data}/&gt; &lt;s:Image src="something.png" visible="{parentDocument.ShowImage}" includeInLayout="{parentDocument.ShowImage}"/&gt; &lt;/s:ItemRenderer&gt; </code></pre> <p>RendererContainer.mxml</p> <pre><code>&lt;s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"&gt; &lt;fx:Script&gt; &lt;![CDATA[ private var showImage:Boolean = false; [Bindable] public function set ShowImage(val:Boolean):void { showImage = val; } public function get ShowImage():Boolean { return showImage; } ]]&gt; &lt;/fx:Script&gt; &lt;!-- Content Group --&gt; &lt;s:List id="lstCell" width="100%" height="100%" itemRenderer="MyItemRenderer"&gt; &lt;/s:List&gt; &lt;/s:Panel&gt; </code></pre> <p>Ok so there is a checkbox in a wrapper outside of RendererContainer.mxml that dispatches a custom event that is handled by changing a Bindable Boolean. The change in that var then changes the ShowImage property on my RendererContainer component. I would expect that the binding would then be picked up by MyItemRenderer but it doesnt seem to be working.</p> <p>So my outer wrapper would access ShowImage like this</p> <pre><code>&lt;comp:RendererContainer id="myId" ShowImage="{myCheckbox.selected}"/&gt; </code></pre>
    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