2013-10-15 3 views
0

Flash Builder 4.6을 사용하고 있습니다. 플렉스 응용 프로그램에서 AdvancedDataGrid을 만듭니다. AdvancedDataGrid 컨트롤의 다섯 번째 행의 rowColor를 변경하고 싶습니다.Flex의 Advanced Datagrid 컨트롤의 행 색상 변경

다음은 나의 코드입니다.

<?xml version="1.0"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:mx="library://ns.adobe.com/flex/mx" 
      xmlns:s="library://ns.adobe.com/flex/spark"> 
<fx:Script> 
    <![CDATA[ 
     import mx.collections.ArrayCollection; 

     [Bindable] 
     private var dpADG:ArrayCollection = new ArrayCollection([ 
      {Row:1, Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99}, 
      {Row:2, Artist:'Pavement', Album:'Brighten the Corners', Price:11.99}, 
      {Row:3, Artist:'Saner', Album:'A Child Once', Price:11.99}, 
      {Row:4, Artist:'Saner', Album:'Helium Wings', Price:12.99}, 
      {Row:5, Artist:'The Doors', Album:'The Doors', Price:10.99}, 
      {Row:6, Artist:'The Doors', Album:'Morrison Hotel', Price:12.99}, 
      {Row:7, Artist:'Grateful Dead', Album:'American Beauty', Price:11.99}, 
      {Row:8, Artist:'Grateful Dead', Album:'In the Dark', Price:11.99}, 
      {Row:9, Artist:'Grateful Dead', Album:'Shakedown Street', Price:11.99}, 
      {Row:10, Artist:'The Doors', Album:'Strange Days', Price:12.99}, 
      {Row:11, Artist:'The Doors', Album:'The Best of the Doors', Price:10.99} 
     ]);      
    ]]> 
</fx:Script> 
<mx:AdvancedDataGrid width="100%" height="100%" dataProvider="{dpADG}" editable="true" 
        selectionMode="none" sortExpertMode="true"> 
    <mx:columns> 
     <mx:AdvancedDataGridColumn dataField="Row" /> 
     <mx:AdvancedDataGridColumn dataField="Artist" /> 
     <mx:AdvancedDataGridColumn dataField="Album" /> 
     <mx:AdvancedDataGridColumn dataField="Price" /> 
    </mx:columns> 
</mx:AdvancedDataGrid>   
</s:Application> 
+0

봐. com/en_US/FlashPlatform/reference/actionscript/3/spark/components/supportClasses/ItemRenderer.html) –

답변

0

나는 AdvancedDataGrid를 사용하여 시도하지 않은하지만 난 내 DataGrid의 행 색상을 설정하려고 한 경우. 나는 그 다음 방법을 갖는 사용자 정의 DataGrid (MXML)를 작성하여 이런 짓을했는지 :

override protected function drawRowBackground(s:Sprite, rowIndex:int, 
        y:Number, height:Number, color:uint, dataIndex:int):void 
{ 
    if(this.rowColorFunction != null) 
    { 
     if(dataIndex < (this.dataProvider as ArrayCollection).length) 
     { 
      var item:Object = (this.dataProvider as ArrayCollection).getItemAt(dataIndex); 
      color = this.rowColorFunction.call(this, item, dataIndex, color); 
     } 
    } 

    super.drawRowBackground(s, rowIndex, y, height, color, dataIndex); 
} 


public function set rowColorFunction(f:Function):void 
{ 
    this._rowColorFunction = f; 
} 

public function get rowColorFunction():Function 
{ 
    return this._rowColorFunction; 
} 

예 : //help.adobe : (HTTP [ItemRenderers]의 개념에

myGrid.rowColorFunction = function(item:Object, dataIndex:int, color:uint):uint 
{ 
    //conditions then return your color here 
} 
+0

제안 해 주셔서 감사합니다. 그러나 ** AdvancedDataGrid **에서 작동하지 않습니다. DataGrid를 사용하여 이미 완료되었지만 ** AdvancedDataGrid **에서 문제가 발생했습니다. –