By default, a table displays data only when all of the data has been fetched and the table can be fully populated. If there are many rows of data, then the length of time that users must wait before any data appears on the screen may be quite long.
If your data source is ready to give you all of the data that it says it has, and you expect
there to be a long wait between requesting data and displaying data, then you can shorten the
waiting period by telling the data source to fetch the data in increments. The data source is
ultimately responsible for defining the size of the increments that it will fetch. For each
increment of data that is fetched and displayed in the table, an extra row is appended to
the last row. This extra row displays a FetchMessage
. The user then clicks the
FetchMessage
to request that the next increment of data be fetched.
The following list describes the work that you must do prepare to fetch data in increments:
Implement a TableDataListener
that knows how to use an
IncrementalFetchEvent
to talk to the data source.
Register your TableDataListener
so that the application can detect that the
user wants to fetch the next increment of data.
Make sure that the data source is set up to know how many rows of data it will say that it has each time you ask it to fetch data.
The following process describes how listeners, events, Table
and the data
source interact to fetch data in increments and display it.
Table
sends an IncrementalFetchEvent
to your implementation of
TableDataListener
.
Your implementation of TableDataListener
tells the data source to fetch more
data.
Once the data is fetched, the data source sends a DataChangedEvent
to
Table
.
Table
displays the fetched data.
After you have done all of the proper preparation, you are ready to set up the table to fetch increments of data.
The following example sets up the table to fetch increments of data.
table.addTableDataListener(myTableDataListener); table.setIncrementalFetchEnabled(true); table.setFetchIncrement(30); table.setFetchMessage("Click here to retrieve next 30 rows.");
Note: You provide the complete text for the FetchMessage
string,
and remember that the increment value is not inserted automatically. It is set by the data
source.