Advanceddatagrid在隐藏可见区域中的列时变为空

时间:2013-06-13 03:49:02

标签: actionscript-3 flex flex3

我们正在flex 3中开发一个高级数据网格,以便在调用特定状态时可以隐藏该数据网格中的列。

在做一个示例时我们遇到了一个问题,我们在datagrid中有一些列,并且我们滚动到最后一列,然后现在我们隐藏了可见区域中的所有列。在此之后,所有列都消失了。在这里,我附上了快照。Datagrid at initial stage

单击“隐藏列”按钮后,高级数据网格将变为 enter image description here

请帮我解决这个问题。

注意:我们尝试在隐藏每一列时使用validateNow()。但是这与我们的项目编辑创造了许多问题。

我的示例代码段:

protected function button1_clickHandler(event:MouseEvent):void
{

myADG.columns[7].visible = false;
myADG.columns[8].visible = false;
myADG.columns[9].visible = false;
myADG.columns[10].visible = false;

}

我的示例代码:

 <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.controls.Alert;
            import mx.core.mx_internal;
            use namespace mx_internal;
            [Bindable]
            private var dpFlat:ArrayCollection = new ArrayCollection([
                {Region:"Southwest", Territory:"Arizona", 
                    Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000}, 
                {Region:"Southwest", Territory:"Arizona", 
                    Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000},  
                {Region:"Southwest", Territory:"Central California", 
                    Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},  
                {Region:"Southwest", Territory:"Nevada", 
                    Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},  
                {Region:"Southwest", Territory:"Northern California", 
                    Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000}, 
                {Region:"Southwest", Territory:"Northern California", 
                    Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000},  
                {Region:"Southwest", Territory:"Southern California", 
                    Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000}, 
                {Region:"Southwest", Territory:"Southern California", 
                    Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000}
            ]);

            protected function button1_clickHandler(event:MouseEvent):void
            {

                myADG.columns[7].visible = false;
                myADG.columns[8].visible = false;
                myADG.columns[9].visible = false;
                myADG.columns[10].visible = false;

            }

        ]]>
    </mx:Script>

    <mx:Panel title="AdvancedDataGrid Control Example"
              height="75%" width="75%" layout="horizontal"
              paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10">

        <mx:AdvancedDataGrid id="myADG" 
                             width="50%" height="60%" 
                             dataProvider="{dpFlat}" horizontalScrollPolicy="on" >        


            <mx:columns>
                <mx:AdvancedDataGridColumn dataField="Region" width="100" headerText="1"/>
                <mx:AdvancedDataGridColumn dataField="Territory" width="100" headerText="2" visible="true"/>
                <mx:AdvancedDataGridColumn dataField="Territory_Rep"
                                           headerText="3" width="100" visible="true"/>
                <mx:AdvancedDataGridColumn dataField="Actual" width="100" headerText="4" visible="true"/>
                <mx:AdvancedDataGridColumn dataField="Estimate" width="100" headerText="5" visible="true"/>
                <mx:AdvancedDataGridColumn dataField="Territory_Rep"
                                           headerText="6" width="100" visible="true"/>
                <mx:AdvancedDataGridColumn dataField="Actual" width="100" headerText="7"/>
                <mx:AdvancedDataGridColumn dataField="Estimate" width="100" headerText="8"/>
                <mx:AdvancedDataGridColumn dataField="Territory_Rep"
                                           headerText="9" width="100"/>
                <mx:AdvancedDataGridColumn dataField="Actual" width="100" headerText="10"/>
                <mx:AdvancedDataGridColumn dataField="Estimate" width="100" headerText="11"/>
            </mx:columns>
        </mx:AdvancedDataGrid>
        <mx:Button label="Hide Columns" click="button1_clickHandler(event)" />

    </mx:Panel>
</mx:Application>

1 个答案:

答案 0 :(得分:0)

在隐藏最后一列之后尝试将horizontalScrollBarPosition设置为0,也许ADG只是处理不好你的情况&gt;&lt;