我正在使用flex 4.5。我想創建Gauge組件Datagrid。Gauge或UI對象在Datagrid或AdvancedDataGrid中呈現在flex 4.5或flex 4中
我正在使用開源com.betterthantomorrow.components。我創建了這樣的自定義組件
<?xml version="1.0" encoding="utf-8"?>
<s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:bttc="com.betterthantomorrow.components.*"
xmlns:gauge="com.betterthantomorrow.components.gauge.*"
xmlns:objects="tekhnia.com.tekhniag.objects.*"
width="30%" height="65" backgroundColor="black" borderColor="black"
creationComplete="init(event)">
<fx:Declarations>
<mx:NumberFormatter precision="1" id="formatter" rounding="nearest" />
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.messaging.channels.StreamingAMFChannel;
[Bindable]
public var cpuValue:Number;
[Bindable]
public var memoryValue:Number;
[Bindable]
public var diskValue:Number;
[Bindable]
public var mycomp:String;
[Bindable]
public var serverName:String;
[Bindable]
public var statusImage:String;
protected function init(event:FlexEvent):void
{
var strValues:String;
var strColors:String;
var strAlphas:String;
strColors="0x009900,0xFFFF00,0xDD0000";
strValues="0,50,70,100";
strAlphas=".8,.8,.8"
var values:Array=strValues.split(",");
var colors:Array=strColors.split(",");
var alphas:Array=strAlphas.split(",");
gauge1.setStyle("alertValues",values);
gauge1.setStyle("alertColors",colors);
gauge1.setStyle("alertAlphas",alphas);
gauge2.setStyle("alertValues",values);
gauge2.setStyle("alertColors",colors);
gauge2.setStyle("alertAlphas",alphas);
gauge.setStyle("alertValues",values);
gauge.setStyle("alertColors",colors);
gauge.setStyle("alertAlphas",alphas);
gauge.invalidateDisplayList();
gauge1.invalidateDisplayList();
gauge2.invalidateDisplayList();
}
]]>
</fx:Script>
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<s:TileGroup width="101" paddingLeft="20" paddingRight="2">
<bttc:Gauge id="gauge"
diameter="50" width="50"
verticalCenter="0" horizontalCenter="-111"
minValue="1" maxValue="10" value="{cpuValue}" valueFormatter="{formatter}"
bigTicks="9" smallTicks="45" showMinMax="false" showValue="false" pointerColor="white"/>
</s:TileGroup>
<s:TileGroup width="101" paddingLeft="20" paddingRight="2">
<bttc:Gauge id="gauge1"
diameter="50" width="50"
verticalCenter="0" horizontalCenter="-111"
minValue="1" maxValue="10" value="{memoryValue}" valueFormatter="{formatter}"
bigTicks="9" smallTicks="45" showMinMax="false" showValue="false" pointerColor="white" automationName="T"/>
</s:TileGroup>
<s:TileGroup width="101" paddingLeft="20" paddingRight="2">
<bttc:Gauge id="gauge2"
diameter="50" width="50"
verticalCenter="0" horizontalCenter="-111"
minValue="1" maxValue="10" value="{diskValue}" valueFormatter="{formatter}"
bigTicks="9" smallTicks="45" showMinMax="false" showValue="false" pointerColor="white"/>
</s:TileGroup>
<s:TileGroup width="40" paddingTop="3">
<s:Image source="assets/led/big/{statusImage}" />
<s:Label color="white" text="{serverName}" textAlign="center"/>
</s:TileGroup>
</s:BorderContainer>
我想在Datagrid中添加此組件。我在網上嘗試了很多。我沒有找到任何幫助。我也讀書。
請幫幫我。我在網站上的某處發現了一個班輪答案:編寫網格渲染器。我不知道如何編寫網格渲染器並將數據值傳遞給它。
我會更多的感謝滿員有人給我指向示例網格渲染器或代碼的指針。