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>ColReorder example - Server-side processing</title>
|
9
|
<link rel="stylesheet" type="text/css" href="../../../media/css/jquery.dataTables.css">
|
10
|
<link rel="stylesheet" type="text/css" href="../css/dataTables.colReorder.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.colReorder.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
|
|
25
|
$(document).ready(function() {
|
26
|
$('#example').dataTable( {
|
27
|
dom: 'Rlfrtip',
|
28
|
processing: true,
|
29
|
serverSide: true,
|
30
|
ajax: "../../../examples/server_side/scripts/objects.php",
|
31
|
columns: [
|
32
|
{ data: "first_name" },
|
33
|
{ data: "last_name" },
|
34
|
{ data: "position" },
|
35
|
{ data: "office" },
|
36
|
{ data: "start_date" },
|
37
|
{ data: "salary" }
|
38
|
]
|
39
|
} );
|
40
|
} );
|
41
|
|
42
|
|
43
|
|
44
|
</script>
|
45
|
</head>
|
46
|
|
47
|
<body class="dt-example">
|
48
|
<div class="container">
|
49
|
<section>
|
50
|
<h1>ColReorder example <span>Server-side processing</span></h1>
|
51
|
|
52
|
<div class="info">
|
53
|
<p>Server-side processing can be exceptionally useful in DataTables when dealing with massive data
|
54
|
sets, and ColReorder works with this as would be expected.</p>
|
55
|
|
56
|
<p>It is recommend that you use object based data with server-side processing and ColReorder, as this
|
57
|
provides easily understandable mapping between the the columns and the data relation on the server,
|
58
|
otherwise you need to work out array indexes on each call!</p>
|
59
|
</div>
|
60
|
|
61
|
<table id="example" class="display" cellspacing="0" width="100%">
|
62
|
<thead>
|
63
|
<tr>
|
64
|
<th>Name</th>
|
65
|
<th>Position</th>
|
66
|
<th>Office</th>
|
67
|
<th>Extn.</th>
|
68
|
<th>Start date</th>
|
69
|
<th>Salary</th>
|
70
|
</tr>
|
71
|
</thead>
|
72
|
|
73
|
<tfoot>
|
74
|
<tr>
|
75
|
<th>Name</th>
|
76
|
<th>Position</th>
|
77
|
<th>Office</th>
|
78
|
<th>Extn.</th>
|
79
|
<th>Start date</th>
|
80
|
<th>Salary</th>
|
81
|
</tr>
|
82
|
</tfoot>
|
83
|
</table>
|
84
|
|
85
|
<ul class="tabs">
|
86
|
<li class="active">Javascript</li>
|
87
|
<li>HTML</li>
|
88
|
<li>CSS</li>
|
89
|
<li>Ajax</li>
|
90
|
<li>Server-side script</li>
|
91
|
</ul>
|
92
|
|
93
|
<div class="tabs">
|
94
|
<div class="js">
|
95
|
<p>The Javascript shown below is used to initialise the table shown in this
|
96
|
example:</p><code class="multiline brush: js;">$(document).ready(function() {
|
97
|
$('#example').dataTable( {
|
98
|
dom: 'Rlfrtip',
|
99
|
processing: true,
|
100
|
serverSide: true,
|
101
|
ajax: "../../../examples/server_side/scripts/objects.php",
|
102
|
columns: [
|
103
|
{ data: "first_name" },
|
104
|
{ data: "last_name" },
|
105
|
{ data: "position" },
|
106
|
{ data: "office" },
|
107
|
{ data: "start_date" },
|
108
|
{ data: "salary" }
|
109
|
]
|
110
|
} );
|
111
|
} );</code>
|
112
|
|
113
|
<p>In addition to the above code, the following Javascript library files are loaded for use in this
|
114
|
example:</p>
|
115
|
|
116
|
<ul>
|
117
|
<li><a href="../../../media/js/jquery.js">../../../media/js/jquery.js</a></li>
|
118
|
<li><a href=
|
119
|
"../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js</a></li>
|
120
|
<li><a href="../js/dataTables.colReorder.js">../js/dataTables.colReorder.js</a></li>
|
121
|
</ul>
|
122
|
</div>
|
123
|
|
124
|
<div class="table">
|
125
|
<p>The HTML shown below is the raw HTML table element, before it has been enhanced by
|
126
|
DataTables:</p>
|
127
|
</div>
|
128
|
|
129
|
<div class="css">
|
130
|
<div>
|
131
|
<p>This example uses a little bit of additional CSS beyond what is loaded from the library
|
132
|
files (below), in order to correctly display the table. The additional CSS used is shown
|
133
|
below:</p><code class="multiline brush: js;"></code>
|
134
|
</div>
|
135
|
|
136
|
<p>The following CSS library files are loaded for use in this example to provide the styling of the
|
137
|
table:</p>
|
138
|
|
139
|
<ul>
|
140
|
<li><a href=
|
141
|
"../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css</a></li>
|
142
|
<li><a href="../css/dataTables.colReorder.css">../css/dataTables.colReorder.css</a></li>
|
143
|
</ul>
|
144
|
</div>
|
145
|
|
146
|
<div class="ajax">
|
147
|
<p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data
|
148
|
will update automatically as any additional data is loaded.</p>
|
149
|
</div>
|
150
|
|
151
|
<div class="php">
|
152
|
<p>The script used to perform the server-side processing for this table is shown below. Please note
|
153
|
that this is just an example script using PHP. Server-side processing scripts can be written in any
|
154
|
language, using <a href="//datatables.net/manual/server-side">the protocol described in the
|
155
|
DataTables documentation</a>.</p>
|
156
|
</div>
|
157
|
</div>
|
158
|
</section>
|
159
|
</div>
|
160
|
|
161
|
<section>
|
162
|
<div class="footer">
|
163
|
<div class="gradient"></div>
|
164
|
|
165
|
<div class="liner">
|
166
|
<h2>Other examples</h2>
|
167
|
|
168
|
<div class="toc">
|
169
|
<div class="toc-group">
|
170
|
<h3><a href="./index.html">Examples</a></h3>
|
171
|
<ul class="toc active">
|
172
|
<li><a href="./simple.html">Basic initialisation</a></li>
|
173
|
<li><a href="./new_init.html">Initialisation using `new`</a></li>
|
174
|
<li><a href="./alt_insert.html">Alternative insert styling</a></li>
|
175
|
<li><a href="./realtime.html">Realtime updating</a></li>
|
176
|
<li><a href="./state_save.html">State saving</a></li>
|
177
|
<li><a href="./scrolling.html">Scrolling table</a></li>
|
178
|
<li><a href="./predefined.html">Predefined column ordering</a></li>
|
179
|
<li><a href="./reset.html">Reset ordering API</a></li>
|
180
|
<li><a href="./colvis.html">ColVis integration</a></li>
|
181
|
<li><a href="./fixedcolumns.html">FixedColumns integration</a></li>
|
182
|
<li><a href="./fixedheader.html">FixedHeader integration</a></li>
|
183
|
<li><a href="./jqueryui.html">jQuery UI styling</a></li>
|
184
|
<li><a href="./col_filter.html">Individual column filtering</a></li>
|
185
|
<li class="active"><a href="./server_side.html">Server-side processing</a></li>
|
186
|
</ul>
|
187
|
</div>
|
188
|
</div>
|
189
|
|
190
|
<div class="epilogue">
|
191
|
<p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full
|
192
|
information about its API properties and methods.<br>
|
193
|
Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and
|
194
|
<a href="http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of
|
195
|
DataTables.</p>
|
196
|
|
197
|
<p class="copyright">DataTables designed and created by <a href=
|
198
|
"http://www.sprymedia.co.uk">SpryMedia Ltd</a> © 2007-2014<br>
|
199
|
DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
|
200
|
</div>
|
201
|
</div>
|
202
|
</div>
|
203
|
</section>
|
204
|
</body>
|
205
|
</html>
|