O'Reilly logo

Moodle JavaScript Cookbook by Alastair Hole

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding paging

In this recipe, we will enable data paging. We will implement the YUI Paginator control, and configure the DataTable to display rows in blocks of five records. The YUI 2 DataTable control is compatible with the Paginator control. This allows us to enable familiar paging controls for our DataTable, which is particularly useful for large data sets.

Getting ready

Open the datatable.js file for editing. We will add an extra configuration object to add to the DataTable constructor.

How to do it...

First, we must include an additional module: yui2-paginator. We do this by modifying the first line of our code as follows:

YUI().use("yui2-datatable", "yui2-paginator", function(Y) {

Below the column definition object, add the following code: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required