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>Scroller example - Server-side processing (5,000,000 rows)</title>
9
	<link rel="stylesheet" type="text/css" href="../../../media/css/jquery.dataTables.css">
10
	<link rel="stylesheet" type="text/css" href="../css/dataTables.scroller.css">
11
	<link rel="stylesheet" type="text/css" href="../../../examples/resources/syntax/shCore.css">
12
	<link rel="stylesheet" type="text/css" href="../../../examples/resources/demo.css">
13
	<style type="text/css" class="init">
14
 
15
	</style>
16
	<script type="text/javascript" language="javascript" src="../../../media/js/jquery.js"></script>
17
	<script type="text/javascript" language="javascript" src="../../../media/js/jquery.dataTables.js"></script>
18
	<script type="text/javascript" language="javascript" src="../js/dataTables.scroller.js"></script>
19
	<script type="text/javascript" language="javascript" src="../../../examples/resources/syntax/shCore.js"></script>
20
	<script type="text/javascript" language="javascript" src="../../../examples/resources/demo.js"></script>
21
	<script type="text/javascript" language="javascript" class="init">
22
 
23
 
24
$(document).ready(function() {
25
	$('#example').DataTable( {
26
		serverSide: true,
27
		ordering: false,
28
		searching: false,
29
		ajax: function ( data, callback, settings ) {
30
			var out = [];
31
 
32
			for ( var i=data.start, ien=data.start+data.length ; i<ien ; i++ ) {
33
				out.push( [ i+'-1', i+'-2', i+'-3', i+'-4', i+'-5' ] );
34
			}
35
 
36
			setTimeout( function () {
37
				callback( {
38
					draw: data.draw,
39
					data: out,
40
					recordsTotal: 5000000,
41
					recordsFiltered: 5000000
42
				} );
43
			}, 50 );
44
		},
45
		dom: "rtiS",
46
		scrollY: 200,
47
		scroller: {
48
			loadingIndicator: true
49
		}
50
	} );
51
} );
52
 
53
 
54
	</script>
55
</head>
56
 
57
<body class="dt-example">
58
	<div class="container">
59
		<section>
60
			<h1>Scroller example <span>Server-side processing (5,000,000 rows)</span></h1>
61
 
62
			<div class="info">
63
				<p>DataTables' server-side processing mode is a feature that naturally fits in with Scroller perfectly.
64
				Server-side processing can be used to show large data sets, with the server being used to do the data
65
				processing, and Scroller optimising the display of the data in a scrolling viewport.</p>
66
 
67
				<p>When using server-side processing, Scroller will wait a small amount of time to allow the scrolling
68
				to finish before requesting more data from the server (200mS by default). This prevents you from DoSing
69
				your own server!</p>
70
 
71
				<p>This example shows Scroller using server-side processing mode and 5 million rows.
72
				<strong>Important</strong> This particular example uses <a href=
73
				"//datatables.net/reference/option/ajax"><code class="option" title=
74
				"DataTables initialisation option">ajax<span>DT</span></code></a> as a function to 'fake' the data to
75
				show Scroller's ability to show large data sets. It does not have a real database behind it! You would
76
				normally not use <a href="//datatables.net/reference/option/ajax"><code class="option" title=
77
				"DataTables initialisation option">ajax<span>DT</span></code></a> as a function to generate data, but
78
				rather as a url for where to fetch the real data!</p>
79
 
80
				<p>In this example we also enable the <code>loadingIndicator</code> option of Scroller to show the end
81
				user what is happening when they scroll passed the currently loaded data.</p>
82
			</div>
83
 
84
			<table id="example" class="display" cellspacing="0" width="100%">
85
				<thead>
86
					<tr>
87
						<th>ID</th>
88
						<th>First name</th>
89
						<th>Last name</th>
90
						<th>ZIP / Post code</th>
91
						<th>Country</th>
92
					</tr>
93
				</thead>
94
			</table>
95
 
96
			<ul class="tabs">
97
				<li class="active">Javascript</li>
98
				<li>HTML</li>
99
				<li>CSS</li>
100
				<li>Ajax</li>
101
				<li>Server-side script</li>
102
			</ul>
103
 
104
			<div class="tabs">
105
				<div class="js">
106
					<p>The Javascript shown below is used to initialise the table shown in this
107
					example:</p><code class="multiline brush: js;">$(document).ready(function() {
108
	$('#example').DataTable( {
109
		serverSide: true,
110
		ordering: false,
111
		searching: false,
112
		ajax: function ( data, callback, settings ) {
113
			var out = [];
114
 
115
			for ( var i=data.start, ien=data.start+data.length ; i&lt;ien ; i++ ) {
116
				out.push( [ i+'-1', i+'-2', i+'-3', i+'-4', i+'-5' ] );
117
			}
118
 
119
			setTimeout( function () {
120
				callback( {
121
					draw: data.draw,
122
					data: out,
123
					recordsTotal: 5000000,
124
					recordsFiltered: 5000000
125
				} );
126
			}, 50 );
127
		},
128
		dom: &quot;rtiS&quot;,
129
		scrollY: 200,
130
		scroller: {
131
			loadingIndicator: true
132
		}
133
	} );
134
} );</code>
135
 
136
					<p>In addition to the above code, the following Javascript library files are loaded for use in this
137
					example:</p>
138
 
139
					<ul>
140
						<li><a href="../../../media/js/jquery.js">../../../media/js/jquery.js</a></li>
141
						<li><a href=
142
						"../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js</a></li>
143
						<li><a href="../js/dataTables.scroller.js">../js/dataTables.scroller.js</a></li>
144
					</ul>
145
				</div>
146
 
147
				<div class="table">
148
					<p>The HTML shown below is the raw HTML table element, before it has been enhanced by
149
					DataTables:</p>
150
				</div>
151
 
152
				<div class="css">
153
					<div>
154
						<p>This example uses a little bit of additional CSS beyond what is loaded from the library
155
						files (below), in order to correctly display the table. The additional CSS used is shown
156
						below:</p><code class="multiline brush: js;"></code>
157
					</div>
158
 
159
					<p>The following CSS library files are loaded for use in this example to provide the styling of the
160
					table:</p>
161
 
162
					<ul>
163
						<li><a href=
164
						"../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css</a></li>
165
						<li><a href="../css/dataTables.scroller.css">../css/dataTables.scroller.css</a></li>
166
					</ul>
167
				</div>
168
 
169
				<div class="ajax">
170
					<p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data
171
					will update automatically as any additional data is loaded.</p>
172
				</div>
173
 
174
				<div class="php">
175
					<p>The script used to perform the server-side processing for this table is shown below. Please note
176
					that this is just an example script using PHP. Server-side processing scripts can be written in any
177
					language, using <a href="//datatables.net/manual/server-side">the protocol described in the
178
					DataTables documentation</a>.</p>
179
				</div>
180
			</div>
181
		</section>
182
	</div>
183
 
184
	<section>
185
		<div class="footer">
186
			<div class="gradient"></div>
187
 
188
			<div class="liner">
189
				<h2>Other examples</h2>
190
 
191
				<div class="toc">
192
					<div class="toc-group">
193
						<h3><a href="./index.html">Examples</a></h3>
194
						<ul class="toc active">
195
							<li><a href="./simple.html">Basic initialisation</a></li>
196
							<li><a href="./state_saving.html">State saving</a></li>
197
							<li><a href="./large_js_source.html">Client-side data source (50,000 rows)</a></li>
198
							<li class="active"><a href="./server-side_processing.html">Server-side processing
199
							(5,000,000 rows)</a></li>
200
							<li><a href="./api_scrolling.html">API</a></li>
201
						</ul>
202
					</div>
203
				</div>
204
 
205
				<div class="epilogue">
206
					<p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full
207
					information about its API properties and methods.<br>
208
					Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and
209
					<a href="http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of
210
					DataTables.</p>
211
 
212
					<p class="copyright">DataTables designed and created by <a href=
213
					"http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2014<br>
214
					DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
215
				</div>
216
			</div>
217
		</div>
218
	</section>
219
</body>
220
</html>