【问题标题】:how to fix Gridview after reloading Grid in Adobe flex在 Adob​​e flex 中重新加载 Grid 后如何修复 Gridview
【发布时间】:2011-02-02 06:09:43
【问题描述】:

我已经搜索了很多,但找不到执行此操作的确切方法... 如果你看一下这个页面,你会更好地理解。 freescale .please 在 IE 中打开这个。这是我的场景...

单击 om power Actuation 出现在左侧导航中的 Analog & Power Management 下。你会得到结果表,上面我有一个显示不同过滤条件的容器。现在找到一个可过滤的标题(将标题名称与过滤器标题匹配),它位于屏幕右侧折叠之外。然后为过滤器练习选择一个值,按它过滤。

now here my problem arises

重新加载结果后,表格视图会回到它的起始位置,这会导致最终用户对结果感到困惑。

所以我的问题是我怎样才能防止我的表格视图回到它的起点?
我希望我的结果应该是这样的..
Value is chosen for filtering, filtering starts, the reloaded values appear in the same screen position, as before the value was chosen

我想过viewStack,但不知道怎么办?
任何建议或解决方案将不胜感激!!!!!!
提前感谢您抽出宝贵时间阅读我的问题。

【问题讨论】:

    标签: flash apache-flex flex3 adobe


    【解决方案1】:

    单击过滤器后立即将数据网格的“horizo​​ntalScrollPosition”存储在变量中。然后在将数据加载到表中后,将水平滚动位置重置回来。

    我在下面提供了一个示例。在此示例中,有一个数据网格和一个按钮。单击按钮时,数据会被加载,我通过在加载数据后设置“horizo​​ntalScrollPosition”值来保持滚动位置。

    <mx:DataGrid id="dataGridsfgh"
                 left="15"
                 top="41"
                 dataProvider="{employeeList}"
                 width="100%"
                 horizontalScrollPolicy="on">
        <mx:columns>
            <mx:DataGridColumn headerText="First Name"
                               dataField="firstname"
                               width="40"/>
            <mx:DataGridColumn headerText="Last Name"
                               dataField="lastname"
                               width="40"/>
            <mx:DataGridColumn headerText="Designation"
                               dataField="designation"
                               width="40"/>
            <mx:DataGridColumn headerText="Contact # (Desk)"
                               dataField="deskphone"
                               width="40"/>
            <mx:DataGridColumn headerText="Contact # (Mobile)"
                               dataField="mobilephone"
                               width="40"/>
            <mx:DataGridColumn headerText="Contact # (Home)"
                               dataField="resphone"
                               width="40"/>
            <mx:DataGridColumn headerText="Address"
                               dataField="address1"
                               width="40"/>
            <mx:DataGridColumn headerText="Address"
                               dataField="address2"
                               width="40"/>
            <mx:DataGridColumn headerText="State"
                               dataField="state"
                               width="40"/>
            <mx:DataGridColumn headerText="Zip"
                               dataField="zip"
                               width="40"/>
            <mx:DataGridColumn headerText="Country"
                               dataField="country"
                               width="40"/>
        </mx:columns>
    </mx:DataGrid>
    <mx:Button x="36"
               y="228"
               label="Save position"
               click="addData();"/>
    

    动作脚本代码:

        private function addData():void
            {
                var temp:int=dataGridsfgh.horizontalScrollPosition;
                var employeeObj:Object=new Object();
                employeeObj.firstname="John";
                employeeObj.lastname="Henry";
                employeeObj.designation="Developer";
                employeeObj.deskphone="XXX-XXX-XXXX";
                employeeObj.mobilephone="XXX-XXX-XXXX";
                employeeObj.resphone="XXX-XXX-XXXX";
                employeeObj.address1="#XXX Seawall Blvd";
                employeeObj.address2="Apt # XXX";
                employeeObj.location="Maui";
                employeeObj.state="Hawaii";
                employeeObj.zip="XXXXX";
                employeeObj.country="U.S";
                employeeList.addItem(employeeObj);
                dataGridsfgh.dataProvider=employeeList;
                dataGridsfgh.invalidateDisplayList();
                dataGridsfgh.horizontalScrollPosition=temp;
            }
    

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-07
      • 2020-01-17
      • 1970-01-01
      • 1970-01-01
      • 2021-03-16
      • 1970-01-01
      • 2011-04-17
      相关资源
      最近更新 更多