Yahoo! Developer Network Home - Help

YDN Site Search

# YUI Library Examples: DataTable Control (beta): Client-side Pagination

# DataTable Control (beta): Client-side Pagination

This example initially loads a large set of data into the RecordSet and enables the built-in client-side pagination features to display a subset rows.

View example in new window.

## Sample Code for this Example

Data:

{"recordsReturned":504, "totalRecords":1397, "startIndex":0, "sort":null, "dir":"asc", "records":[ {"id":"0", "name":"xmlqoyzgmykrphvyiz", "date":"13-Sep-2002", "price":"8370", "number":"8056", "address":"qdfbc", "company":"taufrid", "desc":"pppzhfhcdqcvbirw", "age":"5512", "title":"zticbcd", "phone":"hvdkltabshgakjqmfrvxo", "email":"eodnqepua", "zip":"eodnqepua", "country":"pdibxicpqipbsgnxyjumsza"}, ... ] }

CSS:

/* No custom CSS. */

Markup:

<h6>Example: Client-side Pagination of Large RecordSet</h6> <div id="paginated"></div>

JavaScript:

YAHOO.util.Event.addListener(window, "load", function() { YAHOO.example.ClientPagination = new function() { var myColumnDefs = [ {key:"id", label:"ID"}, {key:"name", label:"Name"}, {key:"date", label:"Date"}, {key:"price", label:"Price"}, {key:"number", label:"Number"}, {key:"address", label:"Address"}, {key:"company", label:"Company"}, {key:"desc", label:"Description"}, {key:"age", label:"Age"}, {key:"title", label:"Title"}, {key:"phone", label:"Phone"}, {key:"email", label:"Email"}, {key:"zip", label:"Zip"}, {key:"country", label:"Country"} ]; // Show over 1000 records this.myDataSource = new YAHOO.util.DataSource("assets/php/json_proxy.php?"); // Show 5000 records -- FireBug must be disabled! //this.myDataSource = new YAHOO.util.DataSource("assets/php/json5000_proxy.php"); this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; this.myDataSource.responseSchema = { resultsList: "records", fields: ["id","name","date","price","number","address","company","desc","age","title","phone","email","zip","country"] }; var oConfigs = { paginated:true, paginator: { rowsPerPage: 100, dropdownOptions: [25,50,100,500] }, initialRequest: "results=504" }; this.myDataTable = new YAHOO.widget.DataTable("paginated", myColumnDefs, this.myDataSource, oConfigs); }; });

### DataTable Control (beta) Examples:

- Basic Example
- Progressive Enhancement
- Custom Cell Formatting
- Nested headers
- JSON Data Over XHR
- XML Data Over XHR With POST
- Textual Data Over XHR
- Local XML Data
- Client-side Pagination
- Client-side Sorting
- Server-side Pagination
- Server-side Sorting
- Server-side Pagination and Sorting, with Browser History Manager
- Fixed Scrolling
- Row Selection
- Cell Selection
- Inline Cell Editing
- Context Menu Integration
- Complex Example of Multiple Features
- Datatable with Autocomplete
- Skinning Model

### More DataTable Control (beta) Resources:

- User's Guide (external)
- API Documentation
- Cheat Sheet PDF (external)

Copyright © 2007 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings