2011-05-12 235 views
7

Adob​​e告訴我們不要在移動設備上使用Datagrid。我正在創建一個具有更多屏幕空間的Blackberry Playbook應用程序,以潛在地顯示數據表。所以出現了一些問題!Flex移動設備上的數據格

  • 如果我不應該使用DataGrid,我應該使用什麼? (列表不計算,因爲在我的應用程序中,我有10個表格,每個列表的列數和列寬都不同)

  • 好的,如果我必須使用Datagrid,如何設置它的大小以顯示正好所有的數據?例如,一些表具有不同的長度的行,所以requestedRowCount = ' - 1'似乎不正常工作(例如參見下文)

守則

<s:DataGrid requestedRowCount="-1" requestedColumnCount="-1" variableRowHeight="true" styleName="dataGrid" id="partiesGrid" dataProvider="{arr1}" skinClass="skins.DataGridSkin" click="navigator.pushView(view.AssessmentInvolvementEditView)"> 
     <s:columns> 
     <s:ArrayList> 
      <s:GridColumn dataField="name" headerText="Name" width="150"/> 
      <s:GridColumn dataField="role" headerText="Role" width="150"/> 
      <s:GridColumn dataField="startdate" headerText="Start" width="100"/> 
      <s:GridColumn dataField="enddate" headerText="End" width="100"/> 
      <s:GridColumn dataField="presponsibility" headerText="Response" width="150"/> 
      <s:GridColumn dataField="pcarer" headerText="Carer" width="110"/> 
      <s:GridColumn dataField="kworker" headerText="Worker" width="110"/> 
      <s:GridColumn dataField="kteam" headerText="Team" width="110"/> 
     </s:ArrayList> 
     </s:columns> 
    </s:DataGrid>` 

結果(注意高度不適合3排,它增加了底部的空間)enter image description here

回答

8

使datagrid僅顯示已添加的數據並不是不可能的,但這不是我會做的,特別是對於移動應用程序。

就個人而言,我會使用包裝在Scroller中的DataGroup(使用virtualLayout = true)設置爲高度/寬度100%(這隻會在數據「溢出」時顯示)。 DataGroups默認設置顯示所有數據。您必須爲數據創建自己的項目渲染器,並可以創建自己的「標題」。

通過這樣做,您可以從網格中刪除大量功能,但這在移動應用程序中很少使用。此外,如果您創建數據組,您可以添加自己的觸摸功能和手勢來完成任務,同時保持網格的「重量」低,以提供良好的用戶體驗。

0

使用寬度=「100%」和高度=「100%」