5
<title>Example: Nested Column Headers</title>
6
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Maven+Pro:400,700">
7
<link rel="stylesheet" href="../../build/cssgrids/grids-min.css">
8
<link rel="stylesheet" href="../assets/css/main.css">
9
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
10
<script src="../../build/yui/yui-min.js"></script>
15
<h1>Example: Nested Column Headers</h1>
20
<div class="yui3-u-3-4">
22
<div class="content"><style scoped>
23
/* custom styles for this example */
24
.example .yui3-datatable {
28
/* css to counter global site css */
33
display: table-caption;
43
<p>The DataTable widget supports nested column headers, which can be defined in the columns definition using the <code>children</code> configuration.</p>
46
<div class="example yui3-skin-sam">
47
<div id="nested" class="yui3-skin-sam dt-example"></div>
49
<script type="text/javascript">
50
YUI().use("datatable-base", function (Y) {
52
{label:"Train Schedule", children:[
54
{label:"Route", children: [
61
{track:"1", from:"Paris", to:"Amsterdam"},
62
{track:"2", from:"Paris", to:"London"},
63
{track:"3", from:"Paris", to:"Zurich"}
66
dt = new Y.DataTable({
69
summary: "Train schedule",
70
caption:"Table with nested column headers"})
77
<h2>Using Nested Column Headers</h2>
79
<p>Use nested columns to visually group related column headers. The <code>children</code> attribute associates a parent column to its descendants. Note that only bottom-level columns will have data values. Any parent columns are there for presentation purposes only and do not hold any data values directly — therefore parent columns may have a <code>label</code> value but a <code>key</code> value is unnecessary.</p>
81
<pre class="code prettyprint"><div id="nested" class="yui3-skin-sam dt-example"></div>
83
<script type="text/javascript">
84
YUI().use("datatable-base", function (Y) {
86
{label:"Train Schedule", children:[
87
{key: "track"},
88
{label:"Route", children: [
89
{key:"from"},
95
{track:"1", from:"Paris", to:"Amsterdam"},
96
{track:"2", from:"Paris", to:"London"},
97
{track:"3", from:"Paris", to:"Zurich"}
100
dt = new Y.DataTable({
103
summary: "Train schedule",
104
caption:"Table with nested column headers"})
105
.render("#nested");
107
</script></pre>
114
<div class="yui3-u-1-4">
115
<div class="sidebar">
119
<div class="sidebox">
121
<h2 class="no-toc">Examples</h2>
125
<ul class="examples">
128
<li data-description="This example illustrates simple DataTable use cases.">
129
<a href="datatable-basic.html">Basic DataTable</a>
134
<li data-description="DataTable loaded with JSON data from a remote webservice via DataSource.Get">
135
<a href="datatable-dsget.html">DataTable + DataSource.Get + JSON Data</a>
140
<li data-description="DataTable loaded with XML data from a remote webservice via DataSource.IO.">
141
<a href="datatable-dsio.html">DataTable + DataSource.IO + XML Data</a>
146
<li data-description="Custom format data for display.">
147
<a href="datatable-formatting.html">Formatting Row Data for Display</a>
152
<li data-description="DataTable with nested column headers.">
153
<a href="datatable-nestedcols.html">Nested Column Headers</a>
158
<li data-description="DataTable with column sorting.">
159
<a href="datatable-sort.html">Column Sorting</a>
164
<li data-description="DataTable with vertical and/or horizontal scrolling rows.">
165
<a href="datatable-scroll.html">Scrolling DataTable</a>
170
<li data-description="Using DataTable's recordType attribute to create calculated, sortable columns.">
171
<a href="datatable-recordtype.html">Sortable generated columns</a>
183
<div class="sidebox">
185
<h2 class="no-toc">Examples That Use This Component</h2>
189
<ul class="examples">
208
<li data-description="Shows how to instantiate multiple Panel instances, and use nested modality to interact with a Datatable.">
209
<a href="../panel/panel-form.html">Creating a Modal Form</a>
222
<script src="../assets/vendor/prettify/prettify-min.js"></script>
223
<script>prettyPrint();</script>