src/cm/media/js/lib/yui/yui_3.10.3/docs/datatable/datatable-nestedcols.html
author Yves-Marie Haussonne <ymh.work+github@gmail.com>
Fri, 09 May 2014 18:35:26 +0200
changeset 656 a84519031134
parent 525 89ef5ed3c48b
permissions -rw-r--r--
add link to "privacy policy" in the header test

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Example: Nested Column Headers</title>
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic">
    <link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css">
    <link rel="stylesheet" href="../assets/css/main.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
    <script src="../../build/yui/yui-min.js"></script>
    
</head>
<body>
<!--
<a href="https://github.com/yui/yui3"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
-->
<div id="doc">
    <div id="hd">
        <h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1>
    </div>
    

            <h1>Example: Nested Column Headers</h1>
    <div class="yui3-g">
        <div class="yui3-u-3-4">
            <div id="main">
                <div class="content"><style scoped>
/* custom styles for this example */
.example .yui3-datatable {
    margin-bottom: 1em;
}

/* css to counter global site css */
.example table {
    width: auto;
}
.example caption {
    display: table-caption;
}
.example th,
.example td {
    text-transform: none;
    border: 0 none;
}
</style>

<div class="intro">
    <p>The DataTable widget supports nested column headers, which can be defined in the columns definition using the <code>children</code> configuration.</p>
</div>

<div class="example yui3-skin-sam">
    <div id="nested" class="yui3-skin-sam dt-example"></div>  <!-- You need this skin class -->

<script type="text/javascript">
YUI().use("datatable-base", function (Y) {
    var nestedCols = [
        {label:"Train Schedule", children:[
            {key: "track"},
            {label:"Route", children: [
                {key:"from"},
                {key:"to"}
            ]}
        ]}
    ],
    data = [
        {track:"1", from:"Paris", to:"Amsterdam"},
        {track:"2", from:"Paris", to:"London"},
        {track:"3", from:"Paris", to:"Zurich"}
    ],

    dt = new Y.DataTable({
        columns: nestedCols,
        data   : data,
        summary: "Train schedule",
        caption:"Table with nested column headers"})
    .render("#nested");
});
</script>

</div>

<h2>Using Nested Column Headers</h2>

<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 &mdash; therefore parent columns may have a <code>label</code> value but a  <code>key</code> value is unnecessary.</p>
<p>
<strong>Note:</strong> be sure to add the <code>yui3-skin-sam</code> classname to the
page's <code>&lt;body&gt;</code> element or to a parent element of the widget in order to apply
the default CSS skin. See <a href="http://yuilibrary.com/yui/docs/tutorials/skins/">Understanding Skinning</a>.
</p>
<pre class="code prettyprint">&lt;div id=&quot;nested&quot; class=&quot;yui3-skin-sam dt-example&quot;&gt;&lt;&#x2F;div&gt;  &lt;!-- You need this skin class --&gt;

&lt;script type=&quot;text&#x2F;javascript&quot;&gt;
YUI().use(&quot;datatable-base&quot;, function (Y) {
var nestedCols = [
    {label:&quot;Train Schedule&quot;, children:[
        {key: &quot;track&quot;},
        {label:&quot;Route&quot;, children: [
            {key:&quot;from&quot;},
            {key:&quot;to&quot;}
        ]}
    ]}
],
data = [
    {track:&quot;1&quot;, from:&quot;Paris&quot;, to:&quot;Amsterdam&quot;},
    {track:&quot;2&quot;, from:&quot;Paris&quot;, to:&quot;London&quot;},
    {track:&quot;3&quot;, from:&quot;Paris&quot;, to:&quot;Zurich&quot;}
],

dt = new Y.DataTable({
    columns: nestedCols,
    data   : data,
    summary: &quot;Train schedule&quot;,
    caption:&quot;Table with nested column headers&quot;})
.render(&quot;#nested&quot;);
});
&lt;&#x2F;script&gt;</pre>


</div>
            </div>
        </div>

        <div class="yui3-u-1-4">
            <div class="sidebar">
                

                
                    <div class="sidebox">
                        <div class="hd">
                            <h2 class="no-toc">Examples</h2>
                        </div>

                        <div class="bd">
                            <ul class="examples">
                                
                                    
                                        <li data-description="This example illustrates simple DataTable use cases.">
                                            <a href="datatable-basic.html">Basic DataTable</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="DataTable loaded with JSON data from a remote webservice via DataSource.Get">
                                            <a href="datatable-dsget.html">DataTable + DataSource.Get + JSON Data</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="DataTable loaded with XML data from a remote webservice via DataSource.IO.">
                                            <a href="datatable-dsio.html">DataTable + DataSource.IO + XML Data</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="Custom format data for display.">
                                            <a href="datatable-formatting.html">Formatting Row Data for Display</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="DataTable with nested column headers.">
                                            <a href="datatable-nestedcols.html">Nested Column Headers</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="DataTable with column sorting.">
                                            <a href="datatable-sort.html">Column Sorting</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="DataTable with vertical and/or horizontal scrolling rows.">
                                            <a href="datatable-scroll.html">Scrolling DataTable</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="Using DataTable&#x27;s recordType attribute to create calculated, sortable columns.">
                                            <a href="datatable-recordtype.html">Sortable generated columns</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="Populating one DataTable from details in the data of another.">
                                            <a href="datatable-masterdetail.html">Master and detail tables</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="Checkbox column that retains checked state when sorting.">
                                            <a href="datatable-chkboxselect.html">Checkbox select column</a>
                                        </li>
                                    
                                
                                    
                                
                            </ul>
                        </div>
                    </div>
                

                
                    <div class="sidebox">
                        <div class="hd">
                            <h2 class="no-toc">Examples That Use This Component</h2>
                        </div>

                        <div class="bd">
                            <ul class="examples">
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                        <li data-description="Shows how to instantiate multiple Panel instances, and use nested modality to interact with a Datatable.">
                                            <a href="../panel/panel-form.html">Creating a Modal Form</a>
                                        </li>
                                    
                                
                            </ul>
                        </div>
                    </div>
                
            </div>
        </div>
    </div>
</div>

<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>

<script>
YUI.Env.Tests = {
    examples: [],
    project: '../assets',
    assets: '../assets/datatable',
    name: 'datatable-nestedcols',
    title: 'Nested Column Headers',
    newWindow: '',
    auto:  false 
};
YUI.Env.Tests.examples.push('datatable-basic');
YUI.Env.Tests.examples.push('datatable-dsget');
YUI.Env.Tests.examples.push('datatable-dsio');
YUI.Env.Tests.examples.push('datatable-formatting');
YUI.Env.Tests.examples.push('datatable-nestedcols');
YUI.Env.Tests.examples.push('datatable-sort');
YUI.Env.Tests.examples.push('datatable-scroll');
YUI.Env.Tests.examples.push('datatable-recordtype');
YUI.Env.Tests.examples.push('datatable-masterdetail');
YUI.Env.Tests.examples.push('datatable-chkboxselect');
YUI.Env.Tests.examples.push('panel-form');

</script>
<script src="../assets/yui/test-runner.js"></script>



</body>
</html>