Hi Oneworld95,
While I don't know of a canned paging DataGrid component, putting one
together is straightforward enough. The following example will page
through subsets of an already populated collection.
You want to start by creating a custom component that binds to the
source data provider (ie:ArrayCollection, etc). Give the component
an attribute that allows you to specify the number of items per
page. Also create a pageData:Array property that you bind to the
datagrid you wish to page through.
So your custom pager control might look something like this:
control:Pager id=myPager
pageSize=6
collection={_model.selectedType.myItems}
index = 0/
... and you would invoke it thusly:
mx:DataGrid
columnCount = 3
rowCount = 2
dataProvider = {myPager.pageData}
Be sure to give the control hasPrev and hasNext boolean properties so
you can bind to your paging buttons appropriately (maybe even set
the 'visible' flag of your buttons based on them). When one of the
buttons are clicked, dispatch an event to cue the control to flag the
next 6 or previous 6 data items as the subset of the 'collection'
that are being returned as the 'pageData'.
There's always a handful of housekeeping chores to keep in mind with
such custom controls, such as a label to indicate to the user that
they are presently at 'Page 5 of 12'; and tracking to make sure they
don't page beyond the data (to be really slick, have the array roll
back around to the top of the collection if they should do so).
It's also possible to create such a paging arrangement that will call
to the server for a new page of information every time the previous
or next button is clicked, but that is quite a bit more complicated
and probably counterproductive. Any array small enough that people
would willingly page through is probably no more than a few hundred
items. It would not be a strain on local system resources to
download and store the array all in one hit, as opposed to calling to
the server over and over again with each click of the 'next' button.
And of course, if you spend an afternoon coding this once, you'll
have it forever. A worthy expenditure of time, imo.
Hope this was useful,
John Mattaboni