1

Flex 4 ヘルプ データグリッドの行全体の fontWeight の setStyle を、その行の任意のセルのセル コンテンツに基づいて動的に太字にするには、itemRenderer が必要です。たとえば、データグリッド全体のセルの内容が文字列「ALL」に等しい場合、データグリッド内のそのセルを含む行全体を「太字」にする必要があります。注: これは XML データではありません。

Render

protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
            super.updateDisplayList(unscaledWidth,unscaledHeight);
            if (data.toString() == "ALL"){
                setStyle("fontWeight","bold");
            }else{
                setStyle("fontWeight","normal");
            }

        }

MXML Code
<mx:VBox width="100%" id="statsGridBox"   height="40%" >
<mx:DataGrid id="statsGrid" width="100%" height="100%" itemRenderer="com.jpmc.ctrbs.dashboard.alarms.renderers.FontWeightRowRender"/>
</mx:VBox>
4

3 に答える 3

2

まず第一に、ハイライトをセル レベルでのみ発生させたい場合は、コードを itemrender "FontWeightRowRender" 内に配置します。

レンダラーでは、次のようなことができます。

            override public function set data(value:Object):void {              
            super.data = value;

            if (String(value) == "ALL") {
                boldText.visible = true;
                normalText.visible = false;                 
            } else {
                boldText.visible = false;
                normalText.visible = true;
            }
        }

<s:Group>       
    <s:Label id="boldText" text="{label}" width="100%" fontWeight="bold"/>
    <s:Label id="normalText" text="{label}" width="100%" fontWeight="normal"/>
</s:Group>  

更新: 行を強調表示する例

            override public function set data(value:Object):void {              
            super.data = value;
                            if (!value) return;             

            if (MyValueObject(value).isBoldRow()) {
                boldText.visible = true;
                normalText.visible = false;                 
            } else {
                boldText.visible = false;
                normalText.visible = true;
            }
        }

MyValueObject.as

     public function isBoldRow():Boolean {
          if ((this.attrib1 == "ALL") || (this.attrib7 === "ALL"))
           return true;
           return false; 
      }
于 2013-10-08T14:20:59.753 に答える