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