Subversion-Projekte lars-tiefland.ci

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
875 lars 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 - Deferred loading of data</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="//code.jquery.com/jquery-1.11.3.min.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
		"processing": true,
24
		"serverSide": true,
25
		"ajax": "scripts/server_processing.php",
26
		"deferLoading": 57
27
	} );
28
} );
29
 
30
	</script>
31
</head>
32
 
33
<body class="dt-example">
34
	<div class="container">
35
		<section>
36
			<h1>DataTables example <span>Deferred loading of data</span></h1>
37
 
38
			<div class="info">
39
				<p>When using DataTables with server-side processing, the default behaviour is to have DataTables automatically make an Ajax call and load the data, removing
40
				anything which might have already been in the table. However, this behaviour might not always be desirable when the first page of the table has already been
41
				preloaded in the HTML (which you might do to ensure accessibility or for performance reasons).</p>
42
 
43
				<p>This automatic Ajax call to get the first page of data can be overridden by using the <a href="//datatables.net/reference/option/deferLoading"><code class=
44
				"option" title="DataTables initialisation option">deferLoading</code></a> initialisation property. It serves two purposes, firstly to indicate that deferred
45
				loading is required, but also to tell DataTables how many records there are in the full table, in this case 57 (this allows the information element and pagination
46
				to be displayed correctly).</p>
47
 
48
				<p>In the example below, the HTML page already has the first 10 rows of data available it in, so we use <a href=
49
				"//datatables.net/reference/option/deferLoading"><code class="option" title="DataTables initialisation option">deferLoading</code></a> to tell DataTables that this
50
				data is available and that it should wait for under interaction (ordering, paging etc) before making an Ajax call.</p>
51
			</div>
52
 
53
			<table id="example" class="display" cellspacing="0" width="100%">
54
				<thead>
55
					<tr>
56
						<th>First name</th>
57
						<th>Last name</th>
58
						<th>Position</th>
59
						<th>Office</th>
60
						<th>Start date</th>
61
						<th>Salary</th>
62
					</tr>
63
				</thead>
64
 
65
				<tfoot>
66
					<tr>
67
						<th>First name</th>
68
						<th>Last name</th>
69
						<th>Position</th>
70
						<th>Office</th>
71
						<th>Start date</th>
72
						<th>Salary</th>
73
					</tr>
74
				</tfoot>
75
 
76
				<tr class="odd">
77
					<td>Airi</td>
78
					<td>Satou</td>
79
					<td>Accountant</td>
80
					<td>Tokyo</td>
81
					<td>28th Nov 08</td>
82
					<td>$162,700</td>
83
				</tr>
84
				<tr class="even">
85
					<td>Angelica</td>
86
					<td>Ramos</td>
87
					<td>Chief Executive Officer (CEO)</td>
88
					<td>London</td>
89
					<td>9th Oct 09</td>
90
					<td>$1,200,000</td>
91
				</tr>
92
				<tr class="odd">
93
					<td>Ashton</td>
94
					<td>Cox</td>
95
					<td>Junior Technical Author</td>
96
					<td>San Francisco</td>
97
					<td>12th Jan 09</td>
98
					<td>$86,000</td>
99
				</tr>
100
				<tr class="even">
101
					<td>Bradley</td>
102
					<td>Greer</td>
103
					<td>Software Engineer</td>
104
					<td>London</td>
105
					<td>13th Oct 12</td>
106
					<td>$132,000</td>
107
				</tr>
108
				<tr class="odd">
109
					<td>Brenden</td>
110
					<td>Wagner</td>
111
					<td>Software Engineer</td>
112
					<td>San Francisco</td>
113
					<td>7th Jun 11</td>
114
					<td>$206,850</td>
115
				</tr>
116
				<tr class="even">
117
					<td>Brielle</td>
118
					<td>Williamson</td>
119
					<td>Integration Specialist</td>
120
					<td>New York</td>
121
					<td>2nd Dec 12</td>
122
					<td>$372,000</td>
123
				</tr>
124
				<tr class="odd">
125
					<td>Bruno</td>
126
					<td>Nash</td>
127
					<td>Software Engineer</td>
128
					<td>London</td>
129
					<td>3rd May 11</td>
130
					<td>$163,500</td>
131
				</tr>
132
				<tr class="even">
133
					<td>Caesar</td>
134
					<td>Vance</td>
135
					<td>Pre-Sales Support</td>
136
					<td>New York</td>
137
					<td>12th Dec 11</td>
138
					<td>$106,450</td>
139
				</tr>
140
				<tr class="odd">
141
					<td>Cara</td>
142
					<td>Stevens</td>
143
					<td>Sales Assistant</td>
144
					<td>New York</td>
145
					<td>6th Dec 11</td>
146
					<td>$145,600</td>
147
				</tr>
148
				<tr class="even">
149
					<td>Cedric</td>
150
					<td>Kelly</td>
151
					<td>Senior Javascript Developer</td>
152
					<td>Edinburgh</td>
153
					<td>29th Mar 12</td>
154
					<td>$433,060</td>
155
				</tr>
156
			</table>
157
 
158
			<ul class="tabs">
159
				<li class="active">Javascript</li>
160
				<li>HTML</li>
161
				<li>CSS</li>
162
				<li>Ajax</li>
163
				<li>Server-side script</li>
164
			</ul>
165
 
166
			<div class="tabs">
167
				<div class="js">
168
					<p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
169
	$('#example').DataTable( {
170
		&quot;processing&quot;: true,
171
		&quot;serverSide&quot;: true,
172
		&quot;ajax&quot;: &quot;scripts/server_processing.php&quot;,
173
		&quot;deferLoading&quot;: 57
174
	} );
175
} );</code>
176
 
177
					<p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
178
 
179
					<ul>
180
						<li><a href="//code.jquery.com/jquery-1.11.3.min.js">//code.jquery.com/jquery-1.11.3.min.js</a></li>
181
						<li><a href="../../media/js/jquery.dataTables.js">../../media/js/jquery.dataTables.js</a></li>
182
					</ul>
183
				</div>
184
 
185
				<div class="table">
186
					<p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
187
				</div>
188
 
189
				<div class="css">
190
					<div>
191
						<p>This example uses a little bit of additional CSS beyond what is loaded from the library files (below), in order to correctly display the table. The
192
						additional CSS used is shown below:</p><code class="multiline language-css"></code>
193
					</div>
194
 
195
					<p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
196
 
197
					<ul>
198
						<li><a href="../../media/css/jquery.dataTables.css">../../media/css/jquery.dataTables.css</a></li>
199
					</ul>
200
				</div>
201
 
202
				<div class="ajax">
203
					<p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data will update automatically as any additional data is
204
					loaded.</p>
205
				</div>
206
 
207
				<div class="php">
208
					<p>The script used to perform the server-side processing for this table is shown below. Please note that this is just an example script using PHP. Server-side
209
					processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
210
					documentation</a>.</p>
211
				</div>
212
			</div>
213
		</section>
214
	</div>
215
 
216
	<section>
217
		<div class="footer">
218
			<div class="gradient"></div>
219
 
220
			<div class="liner">
221
				<h2>Other examples</h2>
222
 
223
				<div class="toc">
224
					<div class="toc-group">
225
						<h3><a href="../basic_init/index.html">Basic initialisation</a></h3>
226
						<ul class="toc">
227
							<li><a href="../basic_init/zero_configuration.html">Zero configuration</a></li>
228
							<li><a href="../basic_init/filter_only.html">Feature enable / disable</a></li>
229
							<li><a href="../basic_init/table_sorting.html">Default ordering (sorting)</a></li>
230
							<li><a href="../basic_init/multi_col_sort.html">Multi-column ordering</a></li>
231
							<li><a href="../basic_init/multiple_tables.html">Multiple tables</a></li>
232
							<li><a href="../basic_init/hidden_columns.html">Hidden columns</a></li>
233
							<li><a href="../basic_init/complex_header.html">Complex headers (rowspan and colspan)</a></li>
234
							<li><a href="../basic_init/dom.html">DOM positioning</a></li>
235
							<li><a href="../basic_init/flexible_width.html">Flexible table width</a></li>
236
							<li><a href="../basic_init/state_save.html">State saving</a></li>
237
							<li><a href="../basic_init/alt_pagination.html">Alternative pagination</a></li>
238
							<li><a href="../basic_init/scroll_y.html">Scroll - vertical</a></li>
239
							<li><a href="../basic_init/scroll_y_dynamic.html">Scroll - vertical, dynamic height</a></li>
240
							<li><a href="../basic_init/scroll_x.html">Scroll - horizontal</a></li>
241
							<li><a href="../basic_init/scroll_xy.html">Scroll - horizontal and vertical</a></li>
242
							<li><a href="../basic_init/comma-decimal.html">Language - Comma decimal place</a></li>
243
							<li><a href="../basic_init/language.html">Language options</a></li>
244
						</ul>
245
					</div>
246
 
247
					<div class="toc-group">
248
						<h3><a href="../advanced_init/index.html">Advanced initialisation</a></h3>
249
						<ul class="toc">
250
							<li><a href="../advanced_init/events_live.html">DOM / jQuery events</a></li>
251
							<li><a href="../advanced_init/dt_events.html">DataTables events</a></li>
252
							<li><a href="../advanced_init/column_render.html">Column rendering</a></li>
253
							<li><a href="../advanced_init/length_menu.html">Page length options</a></li>
254
							<li><a href="../advanced_init/dom_multiple_elements.html">Multiple table control elements</a></li>
255
							<li><a href="../advanced_init/complex_header.html">Complex headers with column visibility</a></li>
256
							<li><a href="../advanced_init/object_dom_read.html">Read HTML to data objects</a></li>
257
							<li><a href="../advanced_init/html5-data-attributes.html">HTML5 data-* attributes - cell data</a></li>
258
							<li><a href="../advanced_init/html5-data-options.html">HTML5 data-* attributes - table options</a></li>
259
							<li><a href="../advanced_init/language_file.html">Language file</a></li>
260
							<li><a href="../advanced_init/defaults.html">Setting defaults</a></li>
261
							<li><a href="../advanced_init/row_callback.html">Row created callback</a></li>
262
							<li><a href="../advanced_init/row_grouping.html">Row grouping</a></li>
263
							<li><a href="../advanced_init/footer_callback.html">Footer callback</a></li>
264
							<li><a href="../advanced_init/dom_toolbar.html">Custom toolbar elements</a></li>
265
							<li><a href="../advanced_init/sort_direction_control.html">Order direction sequence control</a></li>
266
						</ul>
267
					</div>
268
 
269
					<div class="toc-group">
270
						<h3><a href="../styling/index.html">Styling</a></h3>
271
						<ul class="toc">
272
							<li><a href="../styling/display.html">Base style</a></li>
273
							<li><a href="../styling/no-classes.html">Base style - no styling classes</a></li>
274
							<li><a href="../styling/cell-border.html">Base style - cell borders</a></li>
275
							<li><a href="../styling/compact.html">Base style - compact</a></li>
276
							<li><a href="../styling/hover.html">Base style - hover</a></li>
277
							<li><a href="../styling/order-column.html">Base style - order-column</a></li>
278
							<li><a href="../styling/row-border.html">Base style - row borders</a></li>
279
							<li><a href="../styling/stripe.html">Base style - stripe</a></li>
280
							<li><a href="../styling/bootstrap.html">Bootstrap</a></li>
281
							<li><a href="../styling/foundation.html">Foundation</a></li>
282
							<li><a href="../styling/jqueryUI.html">jQuery UI ThemeRoller</a></li>
283
						</ul>
284
					</div>
285
 
286
					<div class="toc-group">
287
						<h3><a href="../data_sources/index.html">Data sources</a></h3>
288
						<ul class="toc">
289
							<li><a href="../data_sources/dom.html">HTML (DOM) sourced data</a></li>
290
							<li><a href="../data_sources/ajax.html">Ajax sourced data</a></li>
291
							<li><a href="../data_sources/js_array.html">Javascript sourced data</a></li>
292
							<li><a href="../data_sources/server_side.html">Server-side processing</a></li>
293
						</ul>
294
					</div>
295
 
296
					<div class="toc-group">
297
						<h3><a href="../api/index.html">API</a></h3>
298
						<ul class="toc">
299
							<li><a href="../api/add_row.html">Add rows</a></li>
300
							<li><a href="../api/multi_filter.html">Individual column searching (text inputs)</a></li>
301
							<li><a href="../api/multi_filter_select.html">Individual column searching (select inputs)</a></li>
302
							<li><a href="../api/highlight.html">Highlighting rows and columns</a></li>
303
							<li><a href="../api/row_details.html">Child rows (show extra / detailed information)</a></li>
304
							<li><a href="../api/select_row.html">Row selection (multiple rows)</a></li>
305
							<li><a href="../api/select_single_row.html">Row selection and deletion (single row)</a></li>
306
							<li><a href="../api/form.html">Form inputs</a></li>
307
							<li><a href="../api/counter_columns.html">Index column</a></li>
308
							<li><a href="../api/show_hide.html">Show / hide columns dynamically</a></li>
309
							<li><a href="../api/api_in_init.html">Using API in callbacks</a></li>
310
							<li><a href="../api/tabs_and_scrolling.html">Scrolling and Bootstrap tabs</a></li>
311
							<li><a href="../api/regex.html">Search API (regular expressions)</a></li>
312
						</ul>
313
					</div>
314
 
315
					<div class="toc-group">
316
						<h3><a href="../ajax/index.html">Ajax</a></h3>
317
						<ul class="toc">
318
							<li><a href="../ajax/simple.html">Ajax data source (arrays)</a></li>
319
							<li><a href="../ajax/objects.html">Ajax data source (objects)</a></li>
320
							<li><a href="../ajax/deep.html">Nested object data (objects)</a></li>
321
							<li><a href="../ajax/objects_subarrays.html">Nested object data (arrays)</a></li>
322
							<li><a href="../ajax/orthogonal-data.html">Orthogonal data</a></li>
323
							<li><a href="../ajax/null_data_source.html">Generated content for a column</a></li>
324
							<li><a href="../ajax/custom_data_property.html">Custom data source property</a></li>
325
							<li><a href="../ajax/custom_data_flat.html">Flat array data source</a></li>
326
							<li><a href="../ajax/defer_render.html">Deferred rendering for speed</a></li>
327
						</ul>
328
					</div>
329
 
330
					<div class="toc-group">
331
						<h3><a href="./index.html">Server-side</a></h3>
332
						<ul class="toc active">
333
							<li><a href="./simple.html">Server-side processing</a></li>
334
							<li><a href="./custom_vars.html">Custom HTTP variables</a></li>
335
							<li><a href="./post.html">POST data</a></li>
336
							<li><a href="./ids.html">Automatic addition of row ID attributes</a></li>
337
							<li><a href="./object_data.html">Object data source</a></li>
338
							<li><a href="./row_details.html">Row details</a></li>
339
							<li><a href="./select_rows.html">Row selection</a></li>
340
							<li><a href="./jsonp.html">JSONP data source for remote domains</a></li>
341
							<li class="active"><a href="./defer_loading.html">Deferred loading of data</a></li>
342
							<li><a href="./pipeline.html">Pipelining data to reduce Ajax calls for paging</a></li>
343
						</ul>
344
					</div>
345
 
346
					<div class="toc-group">
347
						<h3><a href="../plug-ins/index.html">Plug-ins</a></h3>
348
						<ul class="toc">
349
							<li><a href="../plug-ins/api.html">API plug-in methods</a></li>
350
							<li><a href="../plug-ins/sorting_auto.html">Ordering plug-ins (with type detection)</a></li>
351
							<li><a href="../plug-ins/sorting_manual.html">Ordering plug-ins (no type detection)</a></li>
352
							<li><a href="../plug-ins/range_filtering.html">Custom filtering - range search</a></li>
353
							<li><a href="../plug-ins/dom_sort.html">Live DOM ordering</a></li>
354
						</ul>
355
					</div>
356
				</div>
357
 
358
				<div class="epilogue">
359
					<p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
360
					Additionally, there are a wide range of <a href="http://www.datatables.net/extensions">extensions</a> and <a href=
361
					"http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of DataTables.</p>
362
 
363
					<p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2015<br>
364
					DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
365
				</div>
366
			</div>
367
		</div>
368
	</section>
369
</body>
370
</html>