Fetching Table Data in Increments

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.

Reducing the amount of time it takes to display data

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.

What you need to do in preparation

The following list describes the work that you must do prepare to fetch data in increments:

What happens to make incremental fetching work

The following process describes how listeners, events, Table and the data source interact to fetch data in increments and display it.

  1. Table sends an IncrementalFetchEvent to your implementation of TableDataListener.

  2. Your implementation of TableDataListener tells the data source to fetch more data.

  3. Once the data is fetched, the data source sends a DataChangedEvent to Table.

  4. Table displays the fetched data.

Example: Setting up the table to fetch increments of 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.