-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_side_processing.html
229 lines (203 loc) · 11 KB
/
server_side_processing.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" type="image/ico" href="http://www.sprymedia.co.uk/media/images/favicon.ico">
<title>Using DataTable with Editable plugin - Server-side processing</title>
<style type="text/css" title="currentStyle">
@import "media/css/demo_page.css";
@import "media/css/demo_table.css";
@import "media/css/demo_validation.css";
@import "media/css/themes/base/jquery-ui.css";
@import "media/css/themes/smoothness/jquery-ui-1.7.2.custom.css";
</style>
<script src="media/js/jquery.min.js" type="text/javascript"></script>
<script src="media/js/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="media/js/jquery.jeditable.js" type="text/javascript"></script>
<script src="media/js/jquery-ui.js" type="text/javascript"></script>
<script src="media/js/jquery.validate.js" type="text/javascript"></script>
<script src="media/js/jquery.dataTables.editable.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready( function () {
$('#example').dataTable({
"bServerSide": true,
"sAjaxSource": "http://datatables.net/release-datatables/examples/server_side/scripts/jsonp.php",
"fnServerData": function( sUrl, aoData, fnCallback ) {
$.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "jsonp",
"cache": false
} );
},
"aoColumns":[
{
"bVisible" : false
},
{},
{},
{},
{}
]
}
).makeEditable({
sUpdateURL: function(value, settings)
{
return(value); //Simulation of server-side response using a callback function
},
"aoColumns": [
{
cssclass: 'required'
},
{
indicator: 'Saving platforms...',
tooltip: 'Click to edit platforms',
type: 'textarea',
submit:'Save changes'
},
{
indicator: 'Saving Engine Version...',
tooltip: 'Click to select engine version',
loadtext: 'loading...',
type: 'select',
onblur: 'cancel',
submit: 'Ok',
loadurl: 'EngineVersionList.php',
loadtype: 'GET'
},
{
indicator: 'Saving CSS Grade...',
tooltip: 'Click to select CSS Grade',
loadtext: 'loading...',
type: 'select',
onblur: 'submit',
data: "{'':'Please select...', 'A':'A','B':'B','C':'C'}"
}
]
});
} );
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17838786-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body id="dt_example">
<div id="container">
<div class="full_width big">
Editable DataTable example - server-side processing
</div>
<h1>Preamble</h1>
<p>
DataTable Editable plugin works with DataTables in the server-side processing mode. In this example, cells are not placed in the source
of the page - they are loaded from the server-side via JSON. This mode is similar with the <a href="ajax.html">ajax mode</a> because in both cases rows are loaded via ajax call. However in the <a href="ajax.html">ajax mode</a>, once data is loaded sorting, filtering and pagination is done on the client side, and in this mode each time user makes any action new ajax request is sent to the server.</p>
<p>There is just one important thing you need to notice. If you set aoColumns definitions in dataTable and editable number of columns should not match.
In the dataTable plugin number of aoColumns elements should be same as the number of columns in the table. However, in the dataTables editable plugin
number of aoColumns is equal to the number of <strong>visible</strong> columns. If you have five columns in the dataTable and first one is not visible,
in the dataTables editable aoColumns array you will have four elements because each of the elements is applied to the visible cells.</p>
<h1>Live example</h1>
<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th>Rendering engine</th>
<th>Browser</th>
<th>Platform(s)</th>
<th>Engine version</th>
<th>CSS grade</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Rendering engine</th>
<th>Browser</th>
<th>Platform(s)</th>
<th>Engine version</th>
<th>CSS grade</th>
</tr>
</tfoot>
<tbody>
</tbody>
</table>
</div>
<div class="spacer"></div>
<h1>Initialization code</h1>
<p>In the initialization code you will need to pass definitions of the columns according to the <a href="http://www.datatables.net/examples/data_sources/server_side.html">JQuery DataTables server-side processing</a> rules. Note that this is a "fake" server-side processing becuse the same .js file is called each time. Google code do not host php server page therefore on the demo page is used just a simulation.</p>
<pre>
$(document).ready( function () {
$('#example').dataTable({
"bServerSide": true,
"sAjaxSource": "server_processing.js",
"aoColumns":[
{
"bVisible" : false
},
{},
{},
{},
{}
]
}
).makeEditable({
sUpdateURL: function(value, settings)
{
//Simulation of server-side response using a callback function
return(value);
},
"aoColumns": [
{
},
{
indicator: 'Saving platforms...',
tooltip: 'Click to edit platforms',
type: 'textarea',
cssclass: 'required',
submit:'Save changes'
},
{
indicator: 'Saving Engine Version...',
tooltip: 'Click to select engine version',
loadtext: 'loading...',
type: 'select',
onblur: 'cancel',
submit: 'Ok',
loadurl: 'EngineVersionList.php',
loadtype: 'GET'
},
{
indicator: 'Saving CSS Grade...',
tooltip: 'Click to select CSS Grade',
loadtext: 'loading...',
type: 'select',
onblur: 'submit',
data: "{'':'Please select...', 'A':'A','B':'B','C':'C'}"
}
]
});
} );
</pre>
<h1>Other examples</h1>
<ul>
<li><a href="index.html">Basic usage</a></li>
<li><a href="addingrecords.html">Adding a new record</a></li>
<li><a href="custom-editors.html">Custom editors</a></li>
<li><a href="inline-validation.html">Validation of inline cells</a></li>
<li><a href="events.html">Pre-processing and post-processing events</a></li>
<li><a href="customization.html">User interface customizations</a></li>
<li><a href="custom-messages.html">Customization of message dialogs</a></li>
<li><a href="ajax.html">Using Ajax source</a></li>
</ul>
<div id="footer" style="text-align:center;">
<span style="font-size:10px;">
DataTables Editable © Jovan Popovic 2010-2011.<br>
</span>
</div>
</div>
</body>
</html>