1.itemrenderer中控制按钮的显示和隐藏,datagrid水平滚动条拖动,itemrenderer显示错乱问题已解决,代码如下:
<mx:DataGridColumn headerText="操作" dataField="HANDLE_TAG">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" horizontalGap="0">
<mx:Script>
<![CDATA[
import mx.events.FlexEvent;
override public function set data(value:Object):void
{
super.data=value;
if(value.HANDLE_TAG=="1")
{
edit.visible=true;
edit.includeInLayout=true;
adjust.visible=false;
adjust.includeInLayout=false;
see.visible=false;
see.includeInLayout=false;
}
else if(value.HANDLE_TAG=="2")
{
edit.visible=true;
edit.includeInLayout=true;
if(value.BANK_CODE=="ICBC"){
adjust.visible=true;
adjust.includeInLayout=true;
}
else{
adjust.visible=false;
adjust.includeInLayout=false;
}
see.visible=false;
see.includeInLayout=false;
}
else if(value.HANDLE_TAG=="3")
{
see.visible=true;
see.includeInLayout=true;
adjust.visible=false;
adjust.includeInLayout=false;
edit.visible=false;
edit.includeInLayout=false;
}
else{
edit.visible=false;
edit.includeInLayout=false;
adjust.visible=false;
adjust.includeInLayout=false;
see.visible=false;
see.includeInLayout=false;
}
}
]]>
</mx:Script>
<mx:LinkButton id="edit" label="编辑" visible="false"
textDecoration="underline" includeInLayout="false"
click="outerDocument.editReconciliationBalance(data)"/>
<mx:LinkButton id="adjust" label="调整" visible="false"
textDecoration="underline" includeInLayout="false"
click="outerDocument.adjustmentTable(data)"/>
<mx:LinkButton id="see" label="查看" visible="false"
textDecoration="underline" includeInLayout="false"
click="outerDocument.showBalance(data)"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
2.itemrenderer中控制label,不同内容显示不同颜色,水平滚动条拖动问题已解决,例子如下:
<mx:DataGridColumn headerText="银行对账余额" dataField="BANK_BALANCE_RECONCILIATION">
<mx:itemRenderer>
<mx:Component>
<mx:Label text="{data.BANK_BALANCE_RECONCILIATION}">
<mx:Script>
<![CDATA[
override public function set data(value:Object):void
{
super.data=value;
if(value.BANK_CODE=="ICBC")
{
setStyle("color","green");
}
else{
setStyle("color","black");
}
}
override protected function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void{
super.updateDisplayList(unscaledWidth,unscaledHeight);
if(data.BANK_CODE=="ICBC")
{
setStyle("color","green");
}
else{
setStyle("color","black");
}
}
]]>
</mx:Script>
</mx:Label>
<!--
<mx:HBox horizontalAlign="center">
<mx:Script>
<![CDATA[
override public function set data(value:Object):void
{
super.data=value;
if(value.BANK_CODE=="ICBC")
{
bbr.setStyle("color","green");
}
bbr.text=value.BANK_BALANCE_RECONCILIATION;
}
]]>
</mx:Script>
<mx:Label id="bbr"/>
</mx:HBox>
-->
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>