Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 在Flex中更改高级Datagrid控件的行颜色_Apache Flex_Flex4_Flash Builder_Flex3_Advanceddatagrid - Fatal编程技术网

Apache flex 在Flex中更改高级Datagrid控件的行颜色

Apache flex 在Flex中更改高级Datagrid控件的行颜色,apache-flex,flex4,flash-builder,flex3,advanceddatagrid,Apache Flex,Flex4,Flash Builder,Flex3,Advanceddatagrid,我正在使用Flash Builder 4.6。在flex应用程序中创建一个AdvancedDataGrid。我想更改AdvancedDataGrid控件第5行的行颜色 这是我的密码 <?xml version="1.0"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xml

我正在使用Flash Builder 4.6。在flex应用程序中创建一个AdvancedDataGrid。我想更改AdvancedDataGrid控件第5行的行颜色

这是我的密码

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

我没有尝试使用
AdvancedDataGrid
,但是当我尝试设置我的
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;
}

研究一下感谢您的建议的概念,但这在AdvancedDataGrid中不起作用。我已经完成了使用DataGrid,但是AdvancedDataGrid中的问题仍然存在。
myGrid.rowColorFunction = function(item:Object, dataIndex:int, color:uint):uint
{
    //conditions then return your color here
}