1

我正在尝试使用“setStyle”功能在数据网格中的 3 列中设置颜色,并且我能够成功地做到这一点。但是一旦我水平滚动背景颜色就会消失。

在图像“beforeScroll.PNG”中,3 列 header1、header2 和 header3 的背景颜色为灰色,这很好。但是当我水平滚动数据网格(参见“after-1st-Hscroll.PNG”)时,header2 中的颜色消失了,第二次滚动时(参见“after-2st-Hscroll.PNG”),标题 3 中的颜色也消失了。

我正在使用 SDK 4.6.0

![beforeScroll](http://C:/Documents and Settings/p102808/Desktop/New Folder (2)/beforeScroll.PNG)

![after-1st-Hscroll](http://C:/Documents and Settings/p102808/Desktop/New Folder (2)/after-1st-Hscroll.PNG)

![after-2st-Hscroll](http://C:/Documents and Settings/p102808/Desktop/New Folder (2)/after-2nd-Hscroll.PNG)

请在下面找到我的代码:

<?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
                   creationComplete="onComplete()">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
                private function onComplete():void{
                    var colsArr:Array=new Array();
                    var column1:AdvancedDataGridColumn=new AdvancedDataGridColumn();
                    column1.headerText="Header1";
                    column1.setStyle("backgroundColor","0xcccccc");
                    colsArr.push(column1);
                    var column2:AdvancedDataGridColumn=new AdvancedDataGridColumn();
                    column2.headerText="Header2";
                    column2.setStyle("backgroundColor","0xcccccc");
                    colsArr.push(column2);
                    var column3:AdvancedDataGridColumn=new AdvancedDataGridColumn();
                    column3.headerText="Header3";
                    column3.setStyle("backgroundColor","0xcccccc");
                    colsArr.push(column3);
                    var column4:AdvancedDataGridColumn=new AdvancedDataGridColumn();
                    column4.headerText="Header4";
                    colsArr.push(column4);
                    var column5:AdvancedDataGridColumn=new AdvancedDataGridColumn();
                    column5.headerText="Header5";
                    colsArr.push(column5);
                    sampleDG.columns=colsArr;
                    var column6:AdvancedDataGridColumn=new AdvancedDataGridColumn();
                    column6.headerText="Header6";
                    colsArr.push(column6);
                    sampleDG.columns=colsArr;
                    var column7:AdvancedDataGridColumn=new AdvancedDataGridColumn();
                    column7.headerText="Header7";
                    colsArr.push(column7);
                    sampleDG.columns=colsArr;
                    var column8:AdvancedDataGridColumn=new AdvancedDataGridColumn();
                    column8.headerText="Header8";
                    colsArr.push(column8);
                    sampleDG.columns=colsArr;
                    var column9:AdvancedDataGridColumn=new AdvancedDataGridColumn();
                    column9.headerText="Header9";
                    colsArr.push(column9);
                    sampleDG.columns=colsArr;
                    var column10:AdvancedDataGridColumn=new AdvancedDataGridColumn();
                    column10.headerText="Header10";
                    colsArr.push(column10);
                    sampleDG.columns=colsArr;
                    var column11:AdvancedDataGridColumn=new AdvancedDataGridColumn();
                    column11.headerText="Header11";
                    colsArr.push(column11);
                    sampleDG.columns=colsArr;
                    var column12:AdvancedDataGridColumn=new AdvancedDataGridColumn();
                    column12.headerText="Header12";
                    colsArr.push(column12);
                    sampleDG.columns=colsArr;
                }
            ]]>
        </fx:Script>
        <mx:Box horizontalAlign="center" width="100%">


        <mx:AdvancedDataGrid id="sampleDG" rowCount="3" width="70%" horizontalScrollPolicy="on" height="300"/>
        </mx:Box>
    </s:Application>
4

0 回答 0