Not really an answer to my question, but I appreciate the effort.
Main Topics
Browse All TopicsI am porting an HTML type app across to Flex, and am trying to decide the best way of handling data browsing.
For certain types of data (e.g. Customers) there can be a large number of records, so pulling across all the records for browsing is impractical.
I have considered a couple of options, and would like some feedback on them or any suggested alternatives.
1. Page at a time.
This is essentially how the existing system works. It figures out how many rows it has room for, asks the server for the total number of records, and then splits it into pages. That way only a small number of rows (e.g. 30) are pulled across at a time, and tabs are shown at the bottom allowing the user to navigate to any of the available pages. When they click a tab then that page of data is pulled from the server.
2. Populate with blanks, only retrieve visible records.
The idea here is similar but would allow the user to scroll through the data rather than just viewing a single page at a time. Ask the server how many records there are. Create that many blank records. Get enough data to fill the visible rows. When the user scrolls get the required data (or potentially just do this in the background).
Option 2 seems more appealing, but both options limit the ability to make use of the AdvancedDataGrid column sorting.
Is there a nicer way of doing this?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: chrisP4DPosted on 2008-12-05 at 05:22:38ID: 23104535
here's an example of a paginated datagrid you can use in flex. all you have to do is change the init function. you would just replace the data being set for the arraycollection to what you need inside there. this example just loads random data.
.com/2006/ mxml" layout="absolute" creationComplete="InitApp( )" xmlns:MyComp="*"> tion;
; Data.lengt h/pageSize ));
:0}); :set - navSize}); :0});
:pg + 1}); :pages - pageSize});
ckEvent):v oid item.data) ; ); Data.lengt h/pageSize ),event.it em.data);
uint):void t * pageSize),(start * pageSize) + pageSize) ); :DataGrid> ent)" dataProvider="{nav}" width="{dg.width}"></mx:Togg leButtonBa r>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollec
import mx.events.ItemClickEvent;
import mx.controls.Button;
import mx.controls.Alert;
[Bindable]
public var myData:ArrayCollection = new ArrayCollection();
public var orgData:ArrayCollection = new ArrayCollection();
[Bindable]
public var nav:ArrayCollection = new ArrayCollection();
public var pageSize:uint = 10;
public var navSize:uint = 10;
private var index:uint = 0;
private var navPage:uint = 1;
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(index)
createNavBar(Math.ceil(org
}
private function createNavBar(pages:uint = 1,set:uint = 0):void
{
nav.removeAll();
if( pages > 1 )
{
if( set != 0 )
{
nav.addItem({label:"<<",data
if( (set - navSize ) >= 0 )
{
nav.addItem({label:"<",data
}
else
{
nav.addItem({label:"<",data
}
}
for( var x:uint = 0; x < navSize; x++)
{
var pg:uint = x + set;
nav.addItem({label: pg + 1,data: pg});
}
if( pg < pages - 1 )
{
nav.addItem({label:">",data
nav.addItem({label:">>",data
}
}
}
private function navigatePage(event:ItemCli
{
refreshDataProvider(event.
var lb:String = event.item.label.toString(
if( lb.indexOf("<") > -1 || lb.indexOf(">") > -1 )
{
createNavBar(Math.ceil(org
if( event.item.data == 0 )
{
pageNav.selectedIndex = 0;
}
else
{
pageNav.selectedIndex = 2;
}
}
}
private function refreshDataProvider(start:
{
myData = new ArrayCollection( orgData.source.slice((star
}
]]>
</mx:Script>
<mx:VBox verticalGap="0">
<mx:DataGrid id="dg" dataProvider="{myData}"></mx
<mx:ToggleButtonBar id="pageNav" itemClick="navigatePage(ev
</mx:VBox>
</mx:Application>