~smagoun/whoopsie/whoopsie-lp1017637

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/docs/datatable-deprecated/datatable-basic.html

  • Committer: Evan Dandrea
  • Date: 2012-05-09 05:53:45 UTC
  • Revision ID: evan.dandrea@canonical.com-20120509055345-z2j41tmcbf4as5uf
The backend now lives in lp:daisy and the website (errors.ubuntu.com) now lives in lp:errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html>
2
 
<html lang="en">
3
 
<head>
4
 
    <meta charset="utf-8">
5
 
    <title>Example: Basic DataTable</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>
11
 
</head>
12
 
<body>
13
 
 
14
 
<div id="doc">
15
 
    <h1>Example: Basic DataTable</h1>
16
 
 
17
 
    
18
 
 
19
 
    <div class="yui3-g">
20
 
        <div class="yui3-u-3-4">
21
 
            <div id="main">
22
 
                <div class="content"><style scoped>
23
 
/* custom styles for this example */
24
 
.dt-example {margin:1em;}
25
 
 
26
 
/* css to counter global site css */
27
 
.dt-example th {text-transform:none;}
28
 
.dt-example table {width:auto;}
29
 
.dt-example caption {display:table-caption;}
30
 
 
31
 
.notice {
32
 
    background: #faf3d1;
33
 
    border: 1px solid #eac9a9;
34
 
    -moz-border-radius: 3px;
35
 
    -webkit-border-radius: 3px;
36
 
    border-radius: px;
37
 
    padding: 0 1em;
38
 
    -moz-box-shadow: 0 0 5px #ccc8b3;
39
 
    -webkit-box-shadow: 0 0 5px #ccc8b3;
40
 
    box-shadow: 0 0 5px #ccc8b3;
41
 
    margin-bottom: 1em;
42
 
}
43
 
 
44
 
</style>
45
 
 
46
 
<div class="notice">
47
 
    <p>
48
 
        <strong>NOTICE</strong>: This example is for the <strong>deprecated
49
 
        version of DataTable</strong>.  The components referred to here will be
50
 
        removed in future versions of YUI</strong>.  If you are unable to
51
 
        upgrade to <a href="../datatable/index.html">the latest DataTable
52
 
        version</a> due to unresolvable feature conflicts from version 3.4.1 or
53
 
        prior, please <a href="../../../projects/yui3/newticket/">file a
54
 
        ticket</a>.
55
 
    </p>
56
 
</div>
57
 
 
58
 
<div class="intro">
59
 
 
60
 
    <p>The DataTable widget displays data in a tabular format. Use plugins and extensions to add features and functionality to the <code>Y.DataTable.Base</code> class.</p>
61
 
</div>
62
 
 
63
 
<div class="example yui3-skin-sam">
64
 
    <div id="simple" class="yui3-skin-sam dt-example"></div>
65
 
 
66
 
<div id="labels" class="yui3-skin-sam dt-example"></div>
67
 
 
68
 
<script type="text/javascript">
69
 
YUI().use("datatable-base-deprecated", function (Y) {
70
 
    var simpleCols = ["id","name","price"],
71
 
    simpleData = [
72
 
        {id:"ga_3475", name:"gadget", price:"$6.99"},
73
 
        {id:"sp_9980", name:"sprocket", price:"$3.75"},
74
 
        {id:"wi_0650", name:"widget", price:"$4.25"}
75
 
    ],
76
 
    labeledCols = [
77
 
        {key:"mfr_parts_database_id", label:"Mfr Part ID", abbr:"ID"},
78
 
        {key:"mfr_parts_database_name", label:"Mfr Part Name", abbr:"Name"},
79
 
        {key:"mfr_parts_database_price", label:"Wholesale Price", abbr:"Price"}
80
 
    ],
81
 
    labeledData = [
82
 
        {mfr_parts_database_id:"ga_3475", mfr_parts_database_name:"gadget", mfr_parts_database_price:"$6.99"},
83
 
        {mfr_parts_database_id:"sp_9980", mfr_parts_database_name:"sprocket", mfr_parts_database_price:"$3.75"},
84
 
        {mfr_parts_database_id:"wi_0650", mfr_parts_database_name:"widget", mfr_parts_database_price:"$4.25"}
85
 
    ],
86
 
 
87
 
    dt1 = new Y.DataTable.Base({columnset:simpleCols, recordset:simpleData, summary:"Price sheet for inventory parts", caption:"Example table with simple columns"}).render("#simple"),
88
 
    dt2 = new Y.DataTable.Base({columnset:labeledCols, recordset:labeledData, summary:"Price sheet for inventory parts", caption:"These columns have labels and abbrs"}).render("#labels");
89
 
});
90
 
</script>
91
 
 
92
 
</div>
93
 
 
94
 
<h2>Simple DataTable Use Cases</h2>
95
 
 
96
 
<pre class="code prettyprint">&lt;div id=&quot;example&quot; class=&quot;yui3-skin-sam&quot;&gt;&lt;&#x2F;div&gt;</pre>
97
 
 
98
 
 
99
 
 
100
 
<p>A basic table can be rendered into a given container by passing in a simple array of columns and an array of data objects into the constructor. As long as the columns map directly to the keys of the data objects, the table will be generated automatically from the data provided.</p>
101
 
 
102
 
<pre class="code prettyprint">YUI().use(&quot;datatable-base-deprecated&quot;, function(Y) {
103
 
    var cols = [&quot;id&quot;,&quot;name&quot;,&quot;price&quot;],
104
 
    data = [
105
 
        {id:&quot;ga-3475&quot;, name:&quot;gadget&quot;, price:&quot;$6.99&quot;},
106
 
        {id:&quot;sp-9980&quot;, name:&quot;sprocket&quot;, price:&quot;$3.75&quot;},
107
 
        {id:&quot;wi-0650&quot;, name:&quot;widget&quot;, price:&quot;$4.25&quot;}
108
 
    ],
109
 
    dt = new Y.DataTable.Base({
110
 
        columnset: cols,
111
 
        recordset: data,
112
 
        summary: &quot;Price sheet for inventory parts&quot;,
113
 
        caption: &quot;Example table with simple columns&quot;
114
 
    }).render(&quot;#example&quot;);
115
 
});</pre>
116
 
 
117
 
 
118
 
<p>Your column definitions may be an array of object literals in order to support any number of configurations that are supported by the <code>Y.Column</code> class. For instance, you may wish to define a <code>label</code> that will be displayed in each column header. Use the <code>key</code> property to define where data for the column will be coming from.</p>
119
 
 
120
 
<pre class="code prettyprint">YUI().use(&quot;datatable-base-deprecated&quot;, function(Y) {
121
 
    var cols = [
122
 
        { key: &quot;mfr_parts_database_id&quot;, label: &quot;Mfr Part ID&quot;, abbr: &quot;ID&quot;},
123
 
        { key: &quot;mfr_parts_database_name&quot;, label: &quot;Mfr Part Name&quot;, abbr: &quot;Name&quot;},
124
 
        { key: &quot;mfr_parts_database_price&quot;, label: &quot;Wholesale Price&quot;, abbr: &quot;Price&quot;}
125
 
    ],
126
 
    data = [
127
 
        { mfr_parts_database_id: &quot;ga_3475&quot;, mfr_parts_database_name: &quot;gadget&quot;, mfr_parts_database_price: &quot;$6.99&quot;},
128
 
        { mfr_parts_database_id: &quot;sp_9980&quot;, mfr_parts_database_name: &quot;sprocket&quot;, mfr_parts_database_price: &quot;$3.75&quot;},
129
 
        { mfr_parts_database_id: &quot;wi_0650&quot;, mfr_parts_database_name: &quot;widget&quot;, mfr_parts_database_price: &quot;$4.25&quot;}
130
 
    ],
131
 
    dt = new Y.DataTable.Base({
132
 
        columnset: cols,
133
 
        recordset: data,
134
 
        summary: &quot;Price sheet for inventory parts&quot;,
135
 
        caption: &quot;These columns have labels and abbrs&quot;
136
 
    }).render(&quot;#example&quot;);
137
 
});</pre>
138
 
 
139
 
</div>
140
 
            </div>
141
 
        </div>
142
 
 
143
 
        <div class="yui3-u-1-4">
144
 
            <div class="sidebar">
145
 
                
146
 
 
147
 
                
148
 
                    <div class="sidebox">
149
 
                        <div class="hd">
150
 
                            <h2 class="no-toc">Examples</h2>
151
 
                        </div>
152
 
 
153
 
                        <div class="bd">
154
 
                            <ul class="examples">
155
 
                                
156
 
                                    
157
 
                                        <li data-description="This example illustrates simple DataTable use cases.">
158
 
                                            <a href="datatable-basic.html">Basic DataTable</a>
159
 
                                        </li>
160
 
                                    
161
 
                                
162
 
                                    
163
 
                                        <li data-description="DataTable loaded with JSON data from a remote webservice via DataSource.Get">
164
 
                                            <a href="datatable-dsget.html">DataTable + DataSource.Get + JSON Data</a>
165
 
                                        </li>
166
 
                                    
167
 
                                
168
 
                                    
169
 
                                        <li data-description="DataTable loaded with XML data from a remote webservice via DataSource.IO.">
170
 
                                            <a href="datatable-dsio.html">DataTable + DataSource.IO + XML Data</a>
171
 
                                        </li>
172
 
                                    
173
 
                                
174
 
                                    
175
 
                                        <li data-description="Custom format data for display.">
176
 
                                            <a href="datatable-formatting.html">Formatting Row Data for Display</a>
177
 
                                        </li>
178
 
                                    
179
 
                                
180
 
                                    
181
 
                                        <li data-description="DataTable with nested column headers.">
182
 
                                            <a href="datatable-nestedcols.html">Nested Column Headers</a>
183
 
                                        </li>
184
 
                                    
185
 
                                
186
 
                                    
187
 
                                        <li data-description="DataTable with column sorting.">
188
 
                                            <a href="datatable-sort.html">Column Sorting</a>
189
 
                                        </li>
190
 
                                    
191
 
                                
192
 
                                    
193
 
                                        <li data-description="DataTable with vertical and/or horizontal scrolling rows.">
194
 
                                            <a href="datatable-scroll.html">Scrolling DataTable</a>
195
 
                                        </li>
196
 
                                    
197
 
                                
198
 
                            </ul>
199
 
                        </div>
200
 
                    </div>
201
 
                
202
 
 
203
 
                
204
 
            </div>
205
 
        </div>
206
 
    </div>
207
 
</div>
208
 
 
209
 
<script src="../assets/vendor/prettify/prettify-min.js"></script>
210
 
<script>prettyPrint();</script>
211
 
 
212
 
</body>
213
 
</html>