Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 espaco 1
<!DOCTYPE html>
2
<html>
3
<head>
4
        <meta charset="utf-8">
5
        <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
6
        <meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
7
 
8
        <title>DataTables example - Nested object data (arrays)</title>
9
        <link rel="stylesheet" type="text/css" href="../../media/css/jquery.dataTables.css">
10
        <link rel="stylesheet" type="text/css" href="../resources/syntax/shCore.css">
11
        <link rel="stylesheet" type="text/css" href="../resources/demo.css">
12
        <style type="text/css" class="init">
13
 
14
        </style>
15
        <script type="text/javascript" language="javascript" src="../../media/js/jquery.js"></script>
16
        <script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
17
        <script type="text/javascript" language="javascript" src="../resources/syntax/shCore.js"></script>
18
        <script type="text/javascript" language="javascript" src="../resources/demo.js"></script>
19
        <script type="text/javascript" language="javascript" class="init">
20
 
21
$(document).ready(function() {
22
        $('#example').dataTable( {
23
                "ajax": "data/objects_subarrays.txt",
24
                "columns": [
25
                        { "data": "name[, ]" },
26
                        { "data": "hr.0" },
27
                        { "data": "office" },
28
                        { "data": "extn" },
29
                        { "data": "hr.2" },
30
                        { "data": "hr.1" }
31
                ]
32
        } );
33
} );
34
 
35
        </script>
36
</head>
37
 
38
<body class="dt-example">
39
        <div class="container">
40
                <section>
41
                        <h1>DataTables example <span>Nested object data (arrays)</span></h1>
42
 
43
                        <div class="info">
44
                                <p>The information read from an Ajax data source can be arbitrarily complex, but still be displayed by
45
                                DataTables through the <a href="//datatables.net/reference/option/columns.data"><code class="option"
46
                                title="DataTables initialisation option">columns.data<span>DT</span></code></a> option, which is
47
                                particularly useful for working with JSON feeds in an already defined format.</p>
48
 
49
                                <p>The <a href="//datatables.net/reference/option/columns.data"><code class="option" title=
50
                                "DataTables initialisation option">columns.data<span>DT</span></code></a> option has the ability to
51
                                read information not only from objects, but also from arrays using the same dotted object syntax as for
52
                                objects. In addition to this, when working with an array data source <a href=
53
                                "//datatables.net/reference/option/columns.data"><code class="option" title=
54
                                "DataTables initialisation option">columns.data<span>DT</span></code></a> can process the data to
55
                                combine and display the data in simple forms (more complex forms can be defined by using <a href=
56
                                "//datatables.net/reference/option/columns.data"><code class="option" title=
57
                                "DataTables initialisation option">columns.data<span>DT</span></code></a> as a function).</p>
58
 
59
                                <p>This example shows two different aspects of using <a href=
60
                                "//datatables.net/reference/option/columns.data"><code class="option" title=
61
                                "DataTables initialisation option">columns.data<span>DT</span></code></a> to read arrays:</p>
62
 
63
                                <ul class="markdown">
64
                                        <li>The <em>Name</em> column is sourced from an array of two elements (first and last name), which
65
                                        are automatically concatenated together. This is done by using array bracket syntax, with the
66
                                        characters between the brackets being used as the glue between elements (e.g. <code>name[,
67
                                        ]</code>).</li>
68
                                        <li>The <em>Position</em>, <em>Start date</em> and <em>Salary</em> columns are read directly from
69
                                        array elements using dotted object notation (e.g. <code>hr.0</code>). Note that the order in which
70
                                        the data can be used in the columns does not have to match the order in which it is defined in the
71
                                        data source. The structure of the row's data source in this example is:</li>
72
                                </ul>
73
                                <pre>
74
<code class="multiline">{
75
        "name": [
76
                "Nixon",
77
                "Tiger"
78
        ],
79
        "hr": [
80
                "System Architect",
81
                "$3,120",
82
                "2011/04/25"
83
        ],
84
        "office": "Edinburgh",
85
        "extn": "5421"
86
}
87
</code>
88
</pre>
89
                        </div>
90
 
91
                        <table id="example" class="display" cellspacing="0" width="100%">
92
                                <thead>
93
                                        <tr>
94
                                                <th>Name</th>
95
                                                <th>Position</th>
96
                                                <th>Office</th>
97
                                                <th>Extn.</th>
98
                                                <th>Start date</th>
99
                                                <th>Salary</th>
100
                                        </tr>
101
                                </thead>
102
 
103
                                <tfoot>
104
                                        <tr>
105
                                                <th>Name</th>
106
                                                <th>Position</th>
107
                                                <th>Office</th>
108
                                                <th>Extn.</th>
109
                                                <th>Start date</th>
110
                                                <th>Salary</th>
111
                                        </tr>
112
                                </tfoot>
113
                        </table>
114
 
115
                        <ul class="tabs">
116
                                <li class="active">Javascript</li>
117
                                <li>HTML</li>
118
                                <li>CSS</li>
119
                                <li>Ajax</li>
120
                                <li>Server-side script</li>
121
                        </ul>
122
 
123
                        <div class="tabs">
124
                                <div class="js">
125
                                        <p>The Javascript shown below is used to initialise the table shown in this
126
                                        example:</p><code class="multiline brush: js;">$(document).ready(function() {
127
        $('#example').dataTable( {
128
                &quot;ajax&quot;: &quot;data/objects_subarrays.txt&quot;,
129
                &quot;columns&quot;: [
130
                        { &quot;data&quot;: &quot;name[, ]&quot; },
131
                        { &quot;data&quot;: &quot;hr.0&quot; },
132
                        { &quot;data&quot;: &quot;office&quot; },
133
                        { &quot;data&quot;: &quot;extn&quot; },
134
                        { &quot;data&quot;: &quot;hr.2&quot; },
135
                        { &quot;data&quot;: &quot;hr.1&quot; }
136
                ]
137
        } );
138
} );</code>
139
 
140
                                        <p>In addition to the above code, the following Javascript library files are loaded for use in this
141
                                        example:</p>
142
 
143
                                        <ul>
144
                                                <li><a href="../../media/js/jquery.js">../../media/js/jquery.js</a></li>
145
                                                <li><a href="../../media/js/jquery.dataTables.js">../../media/js/jquery.dataTables.js</a></li>
146
                                        </ul>
147
                                </div>
148
 
149
                                <div class="table">
150
                                        <p>The HTML shown below is the raw HTML table element, before it has been enhanced by
151
                                        DataTables:</p>
152
                                </div>
153
 
154
                                <div class="css">
155
                                        <div>
156
                                                <p>This example uses a little bit of additional CSS beyond what is loaded from the library
157
                                                files (below), in order to correctly display the table. The additional CSS used is shown
158
                                                below:</p><code class="multiline brush: js;"></code>
159
                                        </div>
160
 
161
                                        <p>The following CSS library files are loaded for use in this example to provide the styling of the
162
                                        table:</p>
163
 
164
                                        <ul>
165
                                                <li><a href=
166
                                                "../../media/css/jquery.dataTables.css">../../media/css/jquery.dataTables.css</a></li>
167
                                        </ul>
168
                                </div>
169
 
170
                                <div class="ajax">
171
                                        <p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data
172
                                        will update automatically as any additional data is loaded.</p>
173
                                </div>
174
 
175
                                <div class="php">
176
                                        <p>The script used to perform the server-side processing for this table is shown below. Please note
177
                                        that this is just an example script using PHP. Server-side processing scripts can be written in any
178
                                        language, using <a href="//datatables.net/manual/server-side">the protocol described in the
179
                                        DataTables documentation</a>.</p>
180
                                </div>
181
                        </div>
182
                </section>
183
        </div>
184
 
185
        <section>
186
                <div class="footer">
187
                        <div class="gradient"></div>
188
 
189
                        <div class="liner">
190
                                <h2>Other examples</h2>
191
 
192
                                <div class="toc">
193
                                        <div class="toc-group">
194
                                                <h3><a href="../basic_init/index.html">Basic initialisation</a></h3>
195
                                                <ul class="toc">
196
                                                        <li><a href="../basic_init/zero_configuration.html">Zero configuration</a></li>
197
                                                        <li><a href="../basic_init/filter_only.html">Feature enable / disable</a></li>
198
                                                        <li><a href="../basic_init/table_sorting.html">Default ordering (sorting)</a></li>
199
                                                        <li><a href="../basic_init/multi_col_sort.html">Multi-column ordering</a></li>
200
                                                        <li><a href="../basic_init/multiple_tables.html">Multiple tables</a></li>
201
                                                        <li><a href="../basic_init/hidden_columns.html">Hidden columns</a></li>
202
                                                        <li><a href="../basic_init/complex_header.html">Complex headers (rowspan and
203
                                                        colspan)</a></li>
204
                                                        <li><a href="../basic_init/dom.html">DOM positioning</a></li>
205
                                                        <li><a href="../basic_init/flexible_width.html">Flexible table width</a></li>
206
                                                        <li><a href="../basic_init/state_save.html">State saving</a></li>
207
                                                        <li><a href="../basic_init/alt_pagination.html">Alternative pagination</a></li>
208
                                                        <li><a href="../basic_init/scroll_y.html">Scroll - vertical</a></li>
209
                                                        <li><a href="../basic_init/scroll_x.html">Scroll - horizontal</a></li>
210
                                                        <li><a href="../basic_init/scroll_xy.html">Scroll - horizontal and vertical</a></li>
211
                                                        <li><a href="../basic_init/scroll_y_theme.html">Scroll - vertical with jQuery UI
212
                                                        ThemeRoller</a></li>
213
                                                        <li><a href="../basic_init/comma-decimal.html">Language - Comma decimal place</a></li>
214
                                                        <li><a href="../basic_init/language.html">Language options</a></li>
215
                                                </ul>
216
                                        </div>
217
 
218
                                        <div class="toc-group">
219
                                                <h3><a href="../advanced_init/index.html">Advanced initialisation</a></h3>
220
                                                <ul class="toc">
221
                                                        <li><a href="../advanced_init/events_live.html">DOM / jQuery events</a></li>
222
                                                        <li><a href="../advanced_init/dt_events.html">DataTables events</a></li>
223
                                                        <li><a href="../advanced_init/column_render.html">Column rendering</a></li>
224
                                                        <li><a href="../advanced_init/length_menu.html">Page length options</a></li>
225
                                                        <li><a href="../advanced_init/dom_multiple_elements.html">Multiple table control
226
                                                        elements</a></li>
227
                                                        <li><a href="../advanced_init/complex_header.html">Complex headers (rowspan /
228
                                                        colspan)</a></li>
229
                                                        <li><a href="../advanced_init/html5-data-attributes.html">HTML5 data-* attributes</a></li>
230
                                                        <li><a href="../advanced_init/language_file.html">Language file</a></li>
231
                                                        <li><a href="../advanced_init/defaults.html">Setting defaults</a></li>
232
                                                        <li><a href="../advanced_init/row_callback.html">Row created callback</a></li>
233
                                                        <li><a href="../advanced_init/row_grouping.html">Row grouping</a></li>
234
                                                        <li><a href="../advanced_init/footer_callback.html">Footer callback</a></li>
235
                                                        <li><a href="../advanced_init/dom_toolbar.html">Custom toolbar elements</a></li>
236
                                                        <li><a href="../advanced_init/sort_direction_control.html">Order direction sequence
237
                                                        control</a></li>
238
                                                </ul>
239
                                        </div>
240
 
241
                                        <div class="toc-group">
242
                                                <h3><a href="../styling/index.html">Styling</a></h3>
243
                                                <ul class="toc">
244
                                                        <li><a href="../styling/display.html">Base style</a></li>
245
                                                        <li><a href="../styling/no-classes.html">Base style - no styling classes</a></li>
246
                                                        <li><a href="../styling/cell-border.html">Base style - cell borders</a></li>
247
                                                        <li><a href="../styling/compact.html">Base style - compact</a></li>
248
                                                        <li><a href="../styling/hover.html">Base style - hover</a></li>
249
                                                        <li><a href="../styling/order-column.html">Base style - order-column</a></li>
250
                                                        <li><a href="../styling/row-border.html">Base style - row borders</a></li>
251
                                                        <li><a href="../styling/stripe.html">Base style - stripe</a></li>
252
                                                        <li><a href="../styling/bootstrap.html">Bootstrap</a></li>
253
                                                        <li><a href="../styling/foundation.html">Foundation</a></li>
254
                                                        <li><a href="../styling/jqueryUI.html">jQuery UI ThemeRoller</a></li>
255
                                                </ul>
256
                                        </div>
257
 
258
                                        <div class="toc-group">
259
                                                <h3><a href="../data_sources/index.html">Data sources</a></h3>
260
                                                <ul class="toc">
261
                                                        <li><a href="../data_sources/dom.html">HTML (DOM) sourced data</a></li>
262
                                                        <li><a href="../data_sources/ajax.html">Ajax sourced data</a></li>
263
                                                        <li><a href="../data_sources/js_array.html">Javascript sourced data</a></li>
264
                                                        <li><a href="../data_sources/server_side.html">Server-side processing</a></li>
265
                                                </ul>
266
                                        </div>
267
 
268
                                        <div class="toc-group">
269
                                                <h3><a href="../api/index.html">API</a></h3>
270
                                                <ul class="toc">
271
                                                        <li><a href="../api/add_row.html">Add rows</a></li>
272
                                                        <li><a href="../api/multi_filter.html">Individual column searching (text inputs)</a></li>
273
                                                        <li><a href="../api/multi_filter_select.html">Individual column searching (select
274
                                                        inputs)</a></li>
275
                                                        <li><a href="../api/highlight.html">Highlighting rows and columns</a></li>
276
                                                        <li><a href="../api/row_details.html">Child rows (show extra / detailed
277
                                                        information)</a></li>
278
                                                        <li><a href="../api/select_row.html">Row selection (multiple rows)</a></li>
279
                                                        <li><a href="../api/select_single_row.html">Row selection and deletion (single
280
                                                        row)</a></li>
281
                                                        <li><a href="../api/form.html">Form inputs</a></li>
282
                                                        <li><a href="../api/counter_columns.html">Index column</a></li>
283
                                                        <li><a href="../api/show_hide.html">Show / hide columns dynamically</a></li>
284
                                                        <li><a href="../api/api_in_init.html">Using API in callbacks</a></li>
285
                                                        <li><a href="../api/tabs_and_scrolling.html">Scrolling and jQuery UI tabs</a></li>
286
                                                        <li><a href="../api/regex.html">Search API (regular expressions)</a></li>
287
                                                </ul>
288
                                        </div>
289
 
290
                                        <div class="toc-group">
291
                                                <h3><a href="./index.html">Ajax</a></h3>
292
                                                <ul class="toc active">
293
                                                        <li><a href="./simple.html">Ajax data source (arrays)</a></li>
294
                                                        <li><a href="./objects.html">Ajax data source (objects)</a></li>
295
                                                        <li><a href="./deep.html">Nested object data (objects)</a></li>
296
                                                        <li class="active"><a href="./objects_subarrays.html">Nested object data (arrays)</a></li>
297
                                                        <li><a href="./orthogonal-data.html">Orthogonal data</a></li>
298
                                                        <li><a href="./null_data_source.html">Generated content for a column</a></li>
299
                                                        <li><a href="./custom_data_property.html">Custom data source property</a></li>
300
                                                        <li><a href="./custom_data_flat.html">Flat array data source</a></li>
301
                                                        <li><a href="./defer_render.html">Deferred rendering for speed</a></li>
302
                                                </ul>
303
                                        </div>
304
 
305
                                        <div class="toc-group">
306
                                                <h3><a href="../server_side/index.html">Server-side</a></h3>
307
                                                <ul class="toc">
308
                                                        <li><a href="../server_side/simple.html">Server-side processing</a></li>
309
                                                        <li><a href="../server_side/custom_vars.html">Custom HTTP variables</a></li>
310
                                                        <li><a href="../server_side/post.html">POST data</a></li>
311
                                                        <li><a href="../server_side/ids.html">Automatic addition of row ID attributes</a></li>
312
                                                        <li><a href="../server_side/object_data.html">Object data source</a></li>
313
                                                        <li><a href="../server_side/row_details.html">Row details</a></li>
314
                                                        <li><a href="../server_side/select_rows.html">Row selection</a></li>
315
                                                        <li><a href="../server_side/jsonp.html">JSONP data source for remote domains</a></li>
316
                                                        <li><a href="../server_side/defer_loading.html">Deferred loading of data</a></li>
317
                                                        <li><a href="../server_side/pipeline.html">Pipelining data to reduce Ajax calls for
318
                                                        paging</a></li>
319
                                                </ul>
320
                                        </div>
321
 
322
                                        <div class="toc-group">
323
                                                <h3><a href="../plug-ins/index.html">Plug-ins</a></h3>
324
                                                <ul class="toc">
325
                                                        <li><a href="../plug-ins/api.html">API plug-in methods</a></li>
326
                                                        <li><a href="../plug-ins/sorting_auto.html">Ordering plug-ins (with type
327
                                                        detection)</a></li>
328
                                                        <li><a href="../plug-ins/sorting_manual.html">Ordering plug-ins (no type
329
                                                        detection)</a></li>
330
                                                        <li><a href="../plug-ins/range_filtering.html">Custom filtering - range search</a></li>
331
                                                        <li><a href="../plug-ins/dom_sort.html">Live DOM ordering</a></li>
332
                                                </ul>
333
                                        </div>
334
                                </div>
335
 
336
                                <div class="epilogue">
337
                                        <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full
338
                                        information about its API properties and methods.<br>
339
                                        Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and
340
                                        <a href="http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of
341
                                        DataTables.</p>
342
 
343
                                        <p class="copyright">DataTables designed and created by <a href=
344
                                        "http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2014<br>
345
                                        DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
346
                                </div>
347
                        </div>
348
                </div>
349
        </section>
350
</body>
351
</html>