간단한 XML 파일을 사용하여 내 DataGrid의 3 열을 채 웁니다. 마지막 열은 itemrenderer, 기본적으로 Button으로 간주됩니다. 그러나 버튼은 XML 파일의 값에 따라 "true"또는 "false"인 DataGrid의 세 번째 열의 특정 행에만 표시되어야합니다. 그래서 기본적으로 itemrenderer에있는 버튼의 Visible 속성을 true 또는 false로 설정하려고합니다.DataGrid ItemRenderer 오류
Here is the whole application
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" pageTitle="Dynamic Data Grid">
<!-- <s:layout>
<s:VerticalLayout horizontalAlign="center"/>
</s:layout>-->
<fx:Declarations>
<s:ArrayList id="cccb_dp">
<fx:String>User1</fx:String>
<fx:String>User2</fx:String>
<fx:String>User3</fx:String>
</s:ArrayList>
<fx:XML id="tempXML" source="assets/fieldsXML.xml"/>
<s:XMLListCollection id="fieldsXMLList" source="{tempXML.worker}"/>
</fx:Declarations>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:VGroup verticalAlign="middle" horizontalCenter="1" verticalCenter="1" horizontalAlign="center">
<s:HGroup horizontalAlign="center" verticalCenter="-221" width="580" height="158" x="75">
<s:Label text="CC" width="23" height="24" verticalAlign="middle" fontWeight="bold"/>
<s:DropDownList id="cc_cb" dataProvider="{cccb_dp}" width="175"/>
</s:HGroup>
<mx:DataGrid id="myDG" dataProvider="{fieldsXMLList}">
<mx:columns>
<mx:DataGridColumn headerText="Header1" dataField="@field_label"/>
<mx:DataGridColumn headerText="Header2" dataField="@field_value"/>
<mx:DataGridColumn headerText="Header3">
<mx:itemRenderer>
<fx:Component>
<s:Button click="onClick(event)" label="Click Me" dataChange="onDataChange(event)" >
<fx:Script>
<![CDATA[
import mx.controls.Alert;
private function onClick(evt:Event):void
{
Alert.show([email protected]_visibility);
}
private function onDataChange(evt:Event):void
{
[email protected]_visibility;
}
]]>
</fx:Script>
</s:Button>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</s:VGroup>
</s:Application>
The XML:
<worker_fields>
<worker id="1" field_label="Seller" field_value="5" field_visibility="false"/>
<worker id="1" field_label="Balance" field_value="100" field_visibility="true"/>
<worker id="1" field_label="Cash Owned" field_value="300" field_visibility="true"/>
<worker id="2" field_label="Seller" field_value="5" field_visibility="false"/>
<worker id="2" field_label="Balance" field_value="130" field_visibility="true"/>
<worker id="2" field_label="Cash Owned" field_value="132" field_visibility="false"/>
<worker id="2" field_label="Credits" field_value="131" field_visibility="true"/>
</worker_fields>
Any idea how to go around it.
Thanks you for the precious help.
된 XMLList 실패합니다 바인딩 : 당신이 이미 그것을 구현 MX
Button
에서 상속으로 지금까지의 코드는 다음과 같은 것입니다. 'dataChange'접근 방식을 사용하지 않으면 모든 버튼이 표시됩니다. – RIAstar데이터 사용. @ field_visibility는 오류를 제거하지만 여전히 작동하지 않습니다. 나는 두 번째 제안과 똑같은 행동을했다. 버튼이 field_visibility 'true'또는 'false'의 값과 관계없이 column3의 모든 행에 표시되고 있습니다. 생각하세요? – FlexyBoz
@RIAStar 해명 해 주셔서 감사합니다. XML을 그렇게 많이 다루지는 않습니다. – JeffryHouser