在flex中预先水平滚动数据网格时,背景颜色消失

时间:2012-10-11 19:29:59

标签: flex

我想使用“setStyle”函数在预先数据网格中设置3列颜色,我能够成功完成。但只要我水平滚动背景颜色消息,就可以了。

在图像“beforeScroll.PNG”中,3列header1,header2和header3具有背景颜色灰色,这是好的。但是当我滚动数据网格horizo​​ntall(参见“after-1st-Hscroll.PNG”)时,header2的颜色消失,而第2次滚动(参见“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>

0 个答案:

没有答案