This example illustrates how to configure a DataTable instance to page through a large data set managed on the server.
The DataSource will deliver JSON data in the following format:
responseSchema.resultsList
is set to the location in the JSON response of the key holding the list of records for the current page.responseSchema.totalRecords
is set to the location in the JSON response of the key holding the total number of records.For this example, we use a single container rather than allow DataTable to assign its default pagination containers. A custom layout for the pagination controls is used, set in the template
attribute.
Note: the rowsPerPage
configuration is required for all Paginator instances.
Here's the interesting part.
initialRequest
needs to target data that will populate at least the data on the page specified in the Paginator's initialPage
configuration (1 by default).generateRequest
is set to our custom function.paginator
is assigned the Paginator instance.paginationEventHandler
is set to DataTable's default DataSource relay, handleDataSourcePagination
. If more intricate DataSource interaction is needed, assign a custom function.Finally, instantiate the DataTable with the DataSource and configuration.
Note: Logging and debugging is currently turned off for this example.
Copyright © 2008 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Copyright Policy - Job Openings