How to use scope out-of-datagrid variable inside ItemRenderer?

I bind an array of elements to a data grid using ItemRenderer. I use a variable datato manage related data. I also have someComponentVariableone that needs to be inserted into each row, but to declare it in the component area, so the data grid does not seem to re-sort it (compilation error).

How to use this variable ( someComponentVariable) inside ItemRenderer?

Code example

<mx:DataGrid id="userBonusesGrid" width="100" height="248" showHeaders="false" wordWrap="true">
    <mx:columns>
        <mx:DataGridColumn headerText="" width="36">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:VBox verticalAlign="middle" horizontalAlign="center">
                        <ns1:SidePanelBonus 
                            bonusName="{data.name}" description="{data.description}" 
                            arrow="{someComponentVariable}">
                        </ns1:SidePanelBonus>   
                    </mx:VBox>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
    </mx:columns>
</mx:DataGrid>
+3
source share
2 answers

If it someComponentVariableis a public class of a class DataGrid, you can use outerDocumentto access it from component.

<ns1:SidePanelBonus bonusName="{data.name}" description="{data.description}" 
    arrow="{outerDocument.someComponentVariable}">
</ns1:SidePanelBonus>   

. " " outerDocument

+4

, . itemRenderer , . , itemRendrers , , , , , , .

- .

0

Source: https://habr.com/ru/post/1718177/


All Articles