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