2010-10-25 54 views
0

我遇到了問題,我正在使用AdvancedDataGrid。AdvancedDataGrid中的Flex執行超時

它加載大約3000條約20列的記錄。由於網格在LayoutManager內部執行了很多,所以我經常得到Flex執行超時。 我怎樣才能使它成爲一種或更快的呢?

+0

Flex的ADG和DG應該很容易能夠加載3000條記錄。這不應該導致超時。你可以發佈你的代碼或可以用來複制這種行爲的東西嗎? – 2012-02-22 23:15:04

回答

0

使用的Datagrid分頁。

http://gurufaction.blogspot.com/2007/02/flex-datagrid-paging-example-with.html http://stackoverflow.com/questions/1893350/how-does-flex-3-datagrid-paging-work

或像這樣

<?xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="InitApp()" xmlns:MyComp="*"> 
<mx:Script> 
    <![CDATA[ 
     import mx.collections.ArrayCollection; 
     import mx.events.ItemClickEvent; 
     [Bindable] 
     public var myData:ArrayCollection = new ArrayCollection(); 
     public var orgData:ArrayCollection = new ArrayCollection(); 
     [Bindable] 
     public var nav:ArrayCollection = new ArrayCollection(); 
     private var index:int = 0; 
     private var page:int = 25;  
     private var paging:Boolean = true; 

     private function InitApp():void { 
      for(var x:uint = 1; x <= 500; x++) { 
       var obj:Object = new Object(); 
       obj.Id = x.toString(); 
       obj.Name = "Column " + x.toString(); 
       obj.Street = "5555 Street"; 
       obj.Title = "CEO"; 
       obj.City = "El Paso"; 
       orgData.addItem(obj); 
      } 
      refreshDataProvider(0); 
     } 

     private function navPage(d:int):void { 
      index += d; 
      refreshDataProvider(index); 
     } 

     private function refreshDataProvider(start:int):void { 
      if (paging == true) { 
       page = 25; 
       myData = new ArrayCollection(orgData.source.slice(start,start+page)); 
      } 
      else { 
      index = 0; 
       page = 500; 
       myData = new ArrayCollection(orgData.source);    
      } 
      down.enabled = index > 0; 
      up.enabled = index + page < orgData.length; 
      lbl.text = index.toString() + ' to ' + (index + page).toString() + ' of ' + orgData.length;    
     } 

     private function togglePaging():void { 
      paging = !paging; 
      toggle.label = paging.toString(); 
      refreshDataProvider(index); 
     } 

]]> 
</mx:Script> 
    <mx:DataGrid id="dg" dataProvider="{myData}" width="510" height="202"></mx:DataGrid> 
    <mx:Button x="10" y="210" label="&lt;" click="navPage(-25);" id="down"/> 
    <mx:Button x="216" y="210" label="&gt;" click="navPage(25);" id="up"/> 
    <mx:Label x="58" y="212" text="page" width="150" id="lbl"/> 
    <mx:Button x="264" y="210" label="true" id="toggle" click="togglePaging();"/> 

</mx:Application> 
0

一次加載數據塊?說略多於視覺上顯示的許多行。通過這種方式,您可以獲得迅速呈現的感知性能。

3000條記錄被加載了很多在一個去它說的...