Todd Smith![]()
This component is a Y.DataTable class extension that provides the capability to link the displayed `data` within a DataTable to a Paginator View class. This extension was specifically designed to work with Gallery-Paginator-View but could be configured to work with a user's own custom paginator View class.

The extension defines one new DataTable attribute paginator, which represents the only UI element (wherein this extension has no UI). It also defines listeners on the model for the view that updates the DT when `pageChange` events are fired.
A new attribute has been added, paginationSource that when set to "client" will enable client-side pagination.
Prior issues with sorting have been fixed for client-side pagination.
The linked Example demonstrates pagination for "local", "datasource" and "RESTful" servers.
Remote pagination is the BEST application of this component and is the typical use-case, i.e. where it is desired to efficiently look for small segments of data (pages) from a much larger dataset (server data).
To implement server-side pagination the server querystring / url has replaceable parameters (replaced via Y.Lang.sub) that are sent to the server and expected meta data must be returned back in the response (i.e. the number of items in total dataset being critical).
This DT-Paginator also allows for custom querystring (outgoing server request) and response (incoming data returned) mapping to user specified "meta" data that differs from the default PaginatorModel (Please see the Docs and Examples, specifically attribute serverPaginationMap)
Troubleshooting Remote Pagination
NOTE: It is ESSENTIAL that your response includes meta data for totalItems, otherwise the paginator won't render.
If your paged data is available (i.e. in a debugger Net tab) but the paginator doesn't render, this is usually due to the the "totalItems" property in the response not being defined, or often not returned as an integer. Please confirm your server returns this item AND that it is an integer and not a string value.
In addition, if you are attempting server-side pagination but forgot to set "paginationSource: 'remote'" it will default to client-side pagination.
<script src="http://yui.yahooapis.com/3.10.0/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2013.01.16-21-05'
}).use('gallery-datatable-paginator','gallery-paginator-view', function(Y) {
//
// Basic Paginator Example
//
var dtableB = new Y.DataTable({
columns: cols,
data: jsRandom500,
scrollable: 'y',
height: '200px',
paginator: new Y.PaginatorView({
model: new Y.PaginatorModel({ page:3, itemsPerPage:50 }),
container: '#pagContainerBar',
paginatorTemplate: Y.one('#tmpl-bar').getHTML(),
pageOptions: [ 10, 25, 50, 100, 'All' ]
}),
paginatorResize: true,
paginationSource: 'client' // client-side pagination
});
});
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info