Skip to content
bitpshr edited this page Jan 26, 2013 · 10 revisions

Pagination

In contrast to the OnDemandList and OnDemandGrid modules, the Pagination extension implements classic discrete paging controls. It displays a certain number of results at a given time, and provides a footer area with controls to switch between pages.

require([
	"dojo/_base/declare", "dgrid/OnDemandGrid", "dgrid/extensions/Pagination"
], function(declare, Grid, Pagination){
	...
	var CustomGrid = declare([Grid, Pagination]);
	var grid = new CustomGrid({
		store: testStore,
		columns: someColumnObj,
		pagingLinks: false,
		pagingTextBox: true,
		firstLastArrows: true,
		pageSizeOptions: [10, 15, 25]
	}, "grid");
	...
});

Note: the Pagination extension should be mixed into List or Grid, not one of the OnDemand constructors, since those contain their own virtual scrolling logic. Internally, Pagination inherits from the same _StoreMixin module inherited by the OnDemand prototypes for common integration with dojo/store.

API

The Pagination extension exposes the following properties, which can be specified in the arguments object passed to the constructor:

Property Summary

Property Description
rowsPerPage Number of items to show on a given page. Default: 10
previousNextArrows Whether to show arrows which go to the previous/next pages when clicked. Default: true
firstLastArrows Whether to show arrows which jump to the first/last pages when clicked. Default: false
pagingLinks If a positive number is specified, renders a sequence of page numbers around the current page, and for the first and last pages. The number specified indicates how many "neighbors" of the current page are rendered in each direction. If 0 is specified, no page number sequence is rendered. Default: 2
pagingTextBox Whether to show a textbox in place of the current page indicator, to allow immediately jumping to a specific page. Default: false
pageSizeOptions An optional array specifying choices to present for the rowsPerPage property in a drop-down. If unspecified or empty, no drop-down is displayed.

In addition to these properties, the Pagination extension also inherits properties and members supported by dgrid/_StoreMixin; for details, see the first list under OnDemandList in Core Components.

Events

Like OnDemandList, the Pagination extension will emit a dgrid-error event for any error which occurs while attempting to query the store in response to user interaction.

I18n

The Pagination extension retrieves the strings for various parts of its UI from resources in dgrid/extensions/nls, via the dojo/i18n! plugin. These strings are stored in an i18nPagination property on the grid instance, and can be overridden if desired. The optimal point in the lifecycle to override any i18n strings would be in postMixInProperties, or in buildRendering before calling this.inherited(arguments).

Clone this wiki locally