2014-01-31 77 views
0

盡我所能,當我將按鈕放置在spark數據網格中時,我無法蒙皮點火按鈕。我受限於使用光環主題。帶有皮膚按鈕的Flex DataGrid

我已經在單獨的mxml文件中創建了按鈕渲染器;我在dataGrid外部有單獨的按鈕來正確顯示皮膚,所以我相信皮膚沒有任何問題。整個過程就是在外部數據網格中使用相同的皮膚

以下代碼顯示了我所看到的相同行爲;在這種情況下,渲染器是按行創建的。看起來skinClass不受尊重。或者還有另一種方式來做到這一點。

<s:DataGrid id="dg" width="500" dataProvider="{employees2}"> 
    <s:columns> 
     <s:ArrayList> 
      <s:GridColumn dataField="name" headerText="Name"> 
       <s:itemRenderer> 
        <fx:Component> 
         <s:GridItemRenderer> 
          <s:Button label="Press Me" 
             top="0" bottom="0" left="0" right="0" 
             skinClass="MyButtonSkin" /> 
         </s:GridItemRenderer> 
        </fx:Component> 
       </s:itemRenderer> 
      </GridColumn> 
     </s:ArrayList> 
    </s:columns> 
</s:DataGrid> 

在文件MyButtonSkin.mxml

<?xml version="1.0" encoding="utf-8"?> 
<s:SparkButtonSkin xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:fb="http://ns.adobe.com/flashbuilder/2009" 
     minWidth="21" minHeight="21" 
     alpha.disabled="0.5"> 

<fx:Metadata> 
    <![CDATA[ 
    /** 
    * @copy spark.skins.spark.ApplicationSkin#hostComponent 
    */ 
    [HostComponent("spark.components.Button")] 
    ]]> 
</fx:Metadata> 

<fx:Script fb:purpose="styling"> 
    <![CDATA[   
     /* Define the skin elements that should not be colorized. 
     For button, the graphics are colorized but the label is not. */ 
     static private const exclusions:Array = ["labelDisplay"]; 

     /** 
     * @private 
     */  
     override public function get colorizeExclusions():Array {return exclusions;} 

     /** 
     * @private 
     */ 
     override protected function initializationComplete():void 
     { 
      useChromeColor = true; 
      super.initializationComplete(); 
     } 

    ]]>   
</fx:Script> 

<!-- states --> 
<s:states> 
    <s:State name="up" /> 
    <s:State name="over" /> 
    <s:State name="down" /> 
    <s:State name="disabled" /> 
</s:states> 

<!-- layer 2: fill --> 
<!--- @private --> 
<s:Rect id="fill" left="1" right="1" top="1" bottom="1" radiusX="10"> 
    <s:fill> 
     <s:LinearGradient rotation="90"> 
      <s:GradientEntry color="0xFAFAFA" 
          color.over="0xBBBDBD" 
          color.down="0xAAAAAA" 
          alpha="0.85" /> 
      <s:GradientEntry color="0x808080" 
          color.over="0x9FA0A1" 
          color.down="0x929496" 
          alpha="0.85" /> 
     </s:LinearGradient> 
    </s:fill> 
</s:Rect> 

<!-- layer 8: text --> 
<!--- @copy spark.components.supportClasses.ButtonBase#labelDisplay --> 
<s:Label id="labelDisplay" 
     textAlign="center" 
     maxDisplayedLines="1" 
     horizontalCenter="0" verticalCenter="1" verticalAlign="middle"> 
</s:Label> 

</s:SparkButtonSkin> 
+0

那裏更確切的錯誤是什麼?大小/位置? –

+0

'當我把按鈕放在一個spark數據網格中。我受限於使用光環主題'這不是事實。不過你應該使用[GridItemRenderer](https://flex.apache.org/asdoc/spark/components/gridClasses/GridItemRenderer.html)。 – RIAstar

+0

感謝您的回覆。這是使用mx和halo主題創建的大型項目的一小部分;那就是約束進入的地方。慢慢地,我將能夠從mx:halo移動到spark:spark,但現在它們必須共存。 itemRenderer是一個錯字 - 我現在糾正了。 – FlexDash

回答

0

看來,縮放按鈕,網格項目的大小沒有大小的圓角半徑。

我結束了一個按鈕200x200像素的角落半徑爲6像素;它只是無法看到。我把價值提高到了25,現在我可以看到它