YUI Library Home

Site Search (YDN & YUIBlog):

# YUI Library Examples: DataTable Control: Nested Headers

# DataTable Control: Nested Headers

View example in new window.

## Sample Code for this Example

Data:

YAHOO.example.Data = { webstats: [ ["home.html",20,400,44,657], ["blog.html",24,377,97,567], ["contact.html",32,548,42,543], ["about.html",8,465,12,946], ["pagenotfound.html",0,0,0,0] ] }

CSS:

/* No custom CSS. */

Markup:

<div id="nested"></div>

JavaScript:

YAHOO.util.Event.addListener(window, "load", function() { YAHOO.example.NestedHeaders = new function() { var myColumnDefs = [ {key:"page", label:"Page", sortable:true, resizeable:true}, {label:"Statistics", formatter:YAHOO.widget.DataTable.formatNumber, children:[ {label:"Visits", children: [ {key:"visitsmonth", label:"This Month",sortable:true, resizeable:true}, {key:"visitsytd", label:"YTD", abbr:"Year to Date",sortable:true, resizeable:true} ] }, {label:"Views", children: [ {key:"viewsmonth", label:"This Month",sortable:true, resizeable:true}, {key:"viewsytd", label:"YTD", abbr:"Year to Date",sortable:true, resizeable:true} ] } ]} ]; this.myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.webstats); this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; this.myDataSource.responseSchema = { fields: ["page","visitsmonth","visitsytd","viewsmonth","viewsytd"] }; this.myDataTable = new YAHOO.widget.DataTable("nested", myColumnDefs, this.myDataSource); }; });

## Configuration for This Example

You can load the necessary JavaScript and CSS for this example from Yahoo's servers. Click here to load the YUI Dependency Configurator with all of this example's dependencies preconfigured.

### YUI Logger Output:

Note: Logging and debugging is currently turned off for this example.

Reload with logging
and debugging enabled.

### DataTable Control Examples:

- Basic Example
- Progressive Enhancement
- Custom Cell Formatting
- Conditional row coloring
- Nested Headers
- JSON Data Over XHR
- XML Data Over XHR With POST
- XML Data with XPath
- Textual Data Over XHR
- Polling the DataSource
- Adding, Updating, and Deleting Rows
- Client-side Pagination
- Client-side Sorting
- Server-side Pagination and Sorting for Dynamic Data
- Integrating Browser History Manager with Server-side Pagination and Sorting
- XY-scrolling, Y-scrolling, and X-scrolling
- Row Selection
- Cell Selection
- Inline Cell Editing
- Showing, Hiding, and Reordering Columns.
- Highlighting Cells, Rows, or Columns
- Reorder Rows with Drag and Drop
- Row Expansion
- Context Menu Integration
- Configuring the Paginator (included with examples for Paginator)
- TabView Integration
- Complex Example of Multiple Features
- Client-side Filtering of Local Data
- Filtering of Dynamic Data
- Datatable with Autocomplete
- Skinning Model
- Ratings (included with examples for ProgressBar Control)
- YQLDataSource (included with examples for DataSource Utility)
- Complex Application (included with examples for Layout Manager)

### More DataTable Control Resources:

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

Copyright © 2010 Yahoo! Inc. All rights reserved.

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