2011-02-02 57 views
0

我已經搜索了很多,但無法找到確切的方式來做到這一點... 如果你會看看這個網頁,你會明白更好。 freescale。請在IE中打開它。這裏是我的場景...如何修復Gridview後重新加載網格在Adobe Flex

點擊om power Actuation目前在leftnav下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想不出怎麼辦?
任何建議或解決方案將高度讚賞!!!!!
在此先感謝您花費寶貴的時間閱讀我的問題。

回答

2

Store中的可變數據網格的「horizo​​ntalScrollPosition的」當您點擊filter.Then表中加載數據之後儘可能快,復位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();"/> 

ActionScript代碼:

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; 
     } 

希望這有助於!

+0

是的,我認爲它應該工作...讓我檢查然後我會回到你.. – Vivek 2011-02-03 05:36:36

相關問題