English 中文(简体)
高频或高频目标使数据网或先进数据组采用4.5或4法
原标题:Gauge or UI Object render in Datagrid or AdvancedDataGrid in flex 4.5 or flex 4

我正在用4.5法开展工作。 我想要建立Gauge部分数据网。

我是利用公开来源的同学。 我建立了这样的习俗组成部分。

<?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>

我想在数据网中增加这一组成部分。 我已经做了大量的工作。 我找不到任何帮助。 我也阅读了书籍。

请帮助我。 在现场,我发现一个线人回答:书写电网使器。 我没有书写电网使器和将数据价值传递给电网。

我将更加感谢各位给我点人以电网仪或密码。

最佳回答

如果能帮助你,就进行公正的检查。 不要利用你的习俗部分来把所有三个衡量标准汇集在一起,否则,你就能够把这三个衡量标准分开,并提供适当的数据提供者。 你能够确切地实现你想要达到的目标,但随后,你必须处理你作为数据提供者通过的数据。 以下做法似乎较为简单。

<mx:DataGrid id="yourGrid"
             height="388" width="663"
             dataProvider="{yourDP}"

             >
    <mx:columns>
        <mx:DataGridColumn headerText="Type" width="80">
            <mx:itemRenderer>
                <mx:Component>
                    <bttc:Gauge id="gauge1"  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" automationName="T"/>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>

        <mx:DataGridColumn headerText="Type" width="80">
            <mx:itemRenderer>
                <mx:Component>
                    <bttc:Gauge id="gauge2"  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"/>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>

        <mx:DataGridColumn headerText="Type" width="80">
            <mx:itemRenderer>
                <mx:Component>
                    <bttc:Gauge id="gauge3"  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" automationName="T"/>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>

        <mx:DataGridColumn headerText="Type" width="80">
            <mx:itemRenderer>
                <mx:Component>
                    <s:Image source="assets/led/big/{statusImage}" />
                    <s:Label  color="white" text="{serverName}" textAlign="center"/>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>


    </mx:columns> 
</mx:DataGrid>

另一种方式是把整个组成部分作为从上面 cu取的物品:

<mx:DataGrid id="yourGrid"
             height="388" width="663"
             dataProvider="{yourDP}"

             >
    <mx:columns>
        <mx:DataGridColumn headerText="Type" width="80">
            <mx:itemRenderer>
                <mx:Component>
                    <someNameSpace:YourComponent cpuvalue={cpuValue} diskValue={diskValue}/>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>



    </mx:columns> 
</mx:DataGrid>

这里还有一点是,如果贵国的数据提供者被指定为数据提供者的话。 Grid在你的构成部分内具有所有价值,你可以像数据一样获得这些价值。 变量 姓名:

<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="{data.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="{data.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="{data.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="{data.serverName}" textAlign="center"/>
</s:TileGroup>  

in which case you can pass in your component as an item renderer as follows :

<mx:DataGrid  dataProvider="{yourDP}" >
        <mx:columns>
            <mx:DataGridColumn itemRenderer="com.somePath.yourComponent"/>
        </mx:columns>
</mx:DataGrid>

Hope this is of some help.

问题回答

查阅:http://help.adobe.com/en_US/flex/using/WS03d33b8076db57b9-1c32b9124deadc3e9-8000.html 它确切描述了你试图做什么。 我认为,你们需要做的是有一个基于元数据元数据元件的组成部分。





相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Multiple Remote call made simultenously

I was making multiple remote calls and they are done sequentially and when I am getting a result event back it s triggering calls to all the methods with ResultEvent as an argument . I am supposed to ...

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签