| 9 |
lars |
1 |
var TableDatatablesManaged = function () {
|
|
|
2 |
|
|
|
3 |
var initTable1 = function () {
|
|
|
4 |
|
|
|
5 |
var table = $('#sample_1');
|
|
|
6 |
|
|
|
7 |
// begin first table
|
|
|
8 |
table.dataTable({
|
|
|
9 |
|
|
|
10 |
// Internationalisation. For more info refer to http://datatables.net/manual/i18n
|
|
|
11 |
"language": {
|
|
|
12 |
"aria": {
|
|
|
13 |
"sortAscending": ": activate to sort column ascending",
|
|
|
14 |
"sortDescending": ": activate to sort column descending"
|
|
|
15 |
},
|
|
|
16 |
"emptyTable": "No data available in table",
|
|
|
17 |
"info": "Showing _START_ to _END_ of _TOTAL_ records",
|
|
|
18 |
"infoEmpty": "No records found",
|
|
|
19 |
"infoFiltered": "(filtered1 from _MAX_ total records)",
|
|
|
20 |
"lengthMenu": "Show _MENU_",
|
|
|
21 |
"search": "Search:",
|
|
|
22 |
"zeroRecords": "No matching records found",
|
|
|
23 |
"paginate": {
|
|
|
24 |
"previous":"Prev",
|
|
|
25 |
"next": "Next",
|
|
|
26 |
"last": "Last",
|
|
|
27 |
"first": "First"
|
|
|
28 |
}
|
|
|
29 |
},
|
|
|
30 |
|
|
|
31 |
// Or you can use remote translation file
|
|
|
32 |
//"language": {
|
|
|
33 |
// url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
|
|
|
34 |
//},
|
|
|
35 |
|
|
|
36 |
// Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
|
|
|
37 |
// setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
|
|
|
38 |
// So when dropdowns used the scrollable div should be removed.
|
|
|
39 |
//"dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
|
|
|
40 |
|
|
|
41 |
"bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
|
|
|
42 |
|
|
|
43 |
"lengthMenu": [
|
|
|
44 |
[5, 15, 20, -1],
|
|
|
45 |
[5, 15, 20, "All"] // change per page values here
|
|
|
46 |
],
|
|
|
47 |
// set the initial value
|
|
|
48 |
"pageLength": 5,
|
|
|
49 |
"pagingType": "bootstrap_full_number",
|
|
|
50 |
"columnDefs": [
|
|
|
51 |
{ // set default column settings
|
|
|
52 |
'orderable': false,
|
|
|
53 |
'targets': [0]
|
|
|
54 |
},
|
|
|
55 |
{
|
|
|
56 |
"searchable": false,
|
|
|
57 |
"targets": [0]
|
|
|
58 |
},
|
|
|
59 |
{
|
|
|
60 |
"className": "dt-right",
|
|
|
61 |
//"targets": [2]
|
|
|
62 |
}
|
|
|
63 |
],
|
|
|
64 |
"order": [
|
|
|
65 |
[1, "asc"]
|
|
|
66 |
] // set first column as a default sort by asc
|
|
|
67 |
});
|
|
|
68 |
|
|
|
69 |
var tableWrapper = jQuery('#sample_1_wrapper');
|
|
|
70 |
|
|
|
71 |
table.find('.group-checkable').change(function () {
|
|
|
72 |
var set = jQuery(this).attr("data-set");
|
|
|
73 |
var checked = jQuery(this).is(":checked");
|
|
|
74 |
jQuery(set).each(function () {
|
|
|
75 |
if (checked) {
|
|
|
76 |
$(this).prop("checked", true);
|
|
|
77 |
$(this).parents('tr').addClass("active");
|
|
|
78 |
} else {
|
|
|
79 |
$(this).prop("checked", false);
|
|
|
80 |
$(this).parents('tr').removeClass("active");
|
|
|
81 |
}
|
|
|
82 |
});
|
|
|
83 |
});
|
|
|
84 |
|
|
|
85 |
table.on('change', 'tbody tr .checkboxes', function () {
|
|
|
86 |
$(this).parents('tr').toggleClass("active");
|
|
|
87 |
});
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
var initTable2 = function () {
|
|
|
91 |
|
|
|
92 |
var table = $('#sample_2');
|
|
|
93 |
|
|
|
94 |
table.dataTable({
|
|
|
95 |
|
|
|
96 |
// Internationalisation. For more info refer to http://datatables.net/manual/i18n
|
|
|
97 |
"language": {
|
|
|
98 |
"aria": {
|
|
|
99 |
"sortAscending": ": activate to sort column ascending",
|
|
|
100 |
"sortDescending": ": activate to sort column descending"
|
|
|
101 |
},
|
|
|
102 |
"emptyTable": "No data available in table",
|
|
|
103 |
"info": "Showing _START_ to _END_ of _TOTAL_ records",
|
|
|
104 |
"infoEmpty": "No records found",
|
|
|
105 |
"infoFiltered": "(filtered1 from _MAX_ total records)",
|
|
|
106 |
"lengthMenu": "Show _MENU_",
|
|
|
107 |
"search": "Search:",
|
|
|
108 |
"zeroRecords": "No matching records found",
|
|
|
109 |
"paginate": {
|
|
|
110 |
"previous":"Prev",
|
|
|
111 |
"next": "Next",
|
|
|
112 |
"last": "Last",
|
|
|
113 |
"first": "First"
|
|
|
114 |
}
|
|
|
115 |
},
|
|
|
116 |
|
|
|
117 |
// Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
|
|
|
118 |
// setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
|
|
|
119 |
// So when dropdowns used the scrollable div should be removed.
|
|
|
120 |
//"dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
|
|
|
121 |
|
|
|
122 |
"bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
|
|
|
123 |
"pagingType": "bootstrap_extended",
|
|
|
124 |
|
|
|
125 |
"lengthMenu": [
|
|
|
126 |
[5, 15, 20, -1],
|
|
|
127 |
[5, 15, 20, "All"] // change per page values here
|
|
|
128 |
],
|
|
|
129 |
// set the initial value
|
|
|
130 |
"pageLength": 5,
|
|
|
131 |
"columnDefs": [{ // set default column settings
|
|
|
132 |
'orderable': false,
|
|
|
133 |
'targets': [0]
|
|
|
134 |
}, {
|
|
|
135 |
"searchable": false,
|
|
|
136 |
"targets": [0]
|
|
|
137 |
}],
|
|
|
138 |
"order": [
|
|
|
139 |
[1, "asc"]
|
|
|
140 |
] // set first column as a default sort by asc
|
|
|
141 |
});
|
|
|
142 |
|
|
|
143 |
var tableWrapper = jQuery('#sample_2_wrapper');
|
|
|
144 |
|
|
|
145 |
table.find('.group-checkable').change(function () {
|
|
|
146 |
var set = jQuery(this).attr("data-set");
|
|
|
147 |
var checked = jQuery(this).is(":checked");
|
|
|
148 |
jQuery(set).each(function () {
|
|
|
149 |
if (checked) {
|
|
|
150 |
$(this).prop("checked", true);
|
|
|
151 |
} else {
|
|
|
152 |
$(this).prop("checked", false);
|
|
|
153 |
}
|
|
|
154 |
});
|
|
|
155 |
});
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
var initTable3 = function () {
|
|
|
159 |
|
|
|
160 |
var table = $('#sample_3');
|
|
|
161 |
|
|
|
162 |
// begin: third table
|
|
|
163 |
table.dataTable({
|
|
|
164 |
|
|
|
165 |
// Internationalisation. For more info refer to http://datatables.net/manual/i18n
|
|
|
166 |
"language": {
|
|
|
167 |
"aria": {
|
|
|
168 |
"sortAscending": ": activate to sort column ascending",
|
|
|
169 |
"sortDescending": ": activate to sort column descending"
|
|
|
170 |
},
|
|
|
171 |
"emptyTable": "No data available in table",
|
|
|
172 |
"info": "Showing _START_ to _END_ of _TOTAL_ records",
|
|
|
173 |
"infoEmpty": "No records found",
|
|
|
174 |
"infoFiltered": "(filtered1 from _MAX_ total records)",
|
|
|
175 |
"lengthMenu": "Show _MENU_",
|
|
|
176 |
"search": "Search:",
|
|
|
177 |
"zeroRecords": "No matching records found",
|
|
|
178 |
"paginate": {
|
|
|
179 |
"previous":"Prev",
|
|
|
180 |
"next": "Next",
|
|
|
181 |
"last": "Last",
|
|
|
182 |
"first": "First"
|
|
|
183 |
}
|
|
|
184 |
},
|
|
|
185 |
|
|
|
186 |
// Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
|
|
|
187 |
// setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
|
|
|
188 |
// So when dropdowns used the scrollable div should be removed.
|
|
|
189 |
//"dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
|
|
|
190 |
|
|
|
191 |
"bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
|
|
|
192 |
|
|
|
193 |
"lengthMenu": [
|
|
|
194 |
[6, 15, 20, -1],
|
|
|
195 |
[6, 15, 20, "All"] // change per page values here
|
|
|
196 |
],
|
|
|
197 |
// set the initial value
|
|
|
198 |
"pageLength": 6,
|
|
|
199 |
"columnDefs": [{ // set default column settings
|
|
|
200 |
'orderable': false,
|
|
|
201 |
'targets': [0]
|
|
|
202 |
}, {
|
|
|
203 |
"searchable": false,
|
|
|
204 |
"targets": [0]
|
|
|
205 |
}],
|
|
|
206 |
"order": [
|
|
|
207 |
[1, "asc"]
|
|
|
208 |
] // set first column as a default sort by asc
|
|
|
209 |
});
|
|
|
210 |
|
|
|
211 |
var tableWrapper = jQuery('#sample_3_wrapper');
|
|
|
212 |
|
|
|
213 |
table.find('.group-checkable').change(function () {
|
|
|
214 |
var set = jQuery(this).attr("data-set");
|
|
|
215 |
var checked = jQuery(this).is(":checked");
|
|
|
216 |
jQuery(set).each(function () {
|
|
|
217 |
if (checked) {
|
|
|
218 |
$(this).prop("checked", true);
|
|
|
219 |
} else {
|
|
|
220 |
$(this).prop("checked", false);
|
|
|
221 |
}
|
|
|
222 |
});
|
|
|
223 |
});
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
var initTable4 = function () {
|
|
|
227 |
|
|
|
228 |
var table = $('#sample_4');
|
|
|
229 |
|
|
|
230 |
// begin: third table
|
|
|
231 |
table.dataTable({
|
|
|
232 |
|
|
|
233 |
// Internationalisation. For more info refer to http://datatables.net/manual/i18n
|
|
|
234 |
"language": {
|
|
|
235 |
"aria": {
|
|
|
236 |
"sortAscending": ": activate to sort column ascending",
|
|
|
237 |
"sortDescending": ": activate to sort column descending"
|
|
|
238 |
},
|
|
|
239 |
"emptyTable": "No data available in table",
|
|
|
240 |
"info": "Showing _START_ to _END_ of _TOTAL_ records",
|
|
|
241 |
"infoEmpty": "No records found",
|
|
|
242 |
"infoFiltered": "(filtered1 from _MAX_ total records)",
|
|
|
243 |
"lengthMenu": "Show _MENU_",
|
|
|
244 |
"search": "Search:",
|
|
|
245 |
"zeroRecords": "No matching records found",
|
|
|
246 |
"paginate": {
|
|
|
247 |
"previous":"Prev",
|
|
|
248 |
"next": "Next",
|
|
|
249 |
"last": "Last",
|
|
|
250 |
"first": "First"
|
|
|
251 |
}
|
|
|
252 |
},
|
|
|
253 |
|
|
|
254 |
|
|
|
255 |
// Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
|
|
|
256 |
// setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
|
|
|
257 |
// So when dropdowns used the scrollable div should be removed.
|
|
|
258 |
//"dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
|
|
|
259 |
|
|
|
260 |
"bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
|
|
|
261 |
|
|
|
262 |
"lengthMenu": [
|
|
|
263 |
[6, 15, 20, -1],
|
|
|
264 |
[6, 15, 20, "All"] // change per page values here
|
|
|
265 |
],
|
|
|
266 |
// set the initial value
|
|
|
267 |
"pageLength": 6,
|
|
|
268 |
"columnDefs": [{ // set default column settings
|
|
|
269 |
'orderable': false,
|
|
|
270 |
'targets': [0]
|
|
|
271 |
}, {
|
|
|
272 |
"searchable": false,
|
|
|
273 |
"targets": [0]
|
|
|
274 |
}],
|
|
|
275 |
"order": [
|
|
|
276 |
[1, "asc"]
|
|
|
277 |
] // set first column as a default sort by asc
|
|
|
278 |
});
|
|
|
279 |
|
|
|
280 |
var tableWrapper = jQuery('#sample_4_wrapper');
|
|
|
281 |
|
|
|
282 |
table.find('.group-checkable').change(function () {
|
|
|
283 |
var set = jQuery(this).attr("data-set");
|
|
|
284 |
var checked = jQuery(this).is(":checked");
|
|
|
285 |
jQuery(set).each(function () {
|
|
|
286 |
if (checked) {
|
|
|
287 |
$(this).prop("checked", true);
|
|
|
288 |
} else {
|
|
|
289 |
$(this).prop("checked", false);
|
|
|
290 |
}
|
|
|
291 |
});
|
|
|
292 |
});
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
var initTable5 = function () {
|
|
|
296 |
|
|
|
297 |
var table = $('#sample_5');
|
|
|
298 |
|
|
|
299 |
// begin: third table
|
|
|
300 |
table.dataTable({
|
|
|
301 |
|
|
|
302 |
// Internationalisation. For more info refer to http://datatables.net/manual/i18n
|
|
|
303 |
"language": {
|
|
|
304 |
"aria": {
|
|
|
305 |
"sortAscending": ": activate to sort column ascending",
|
|
|
306 |
"sortDescending": ": activate to sort column descending"
|
|
|
307 |
},
|
|
|
308 |
"emptyTable": "No data available in table",
|
|
|
309 |
"info": "Showing _START_ to _END_ of _TOTAL_ records",
|
|
|
310 |
"infoEmpty": "No records found",
|
|
|
311 |
"infoFiltered": "(filtered1 from _MAX_ total records)",
|
|
|
312 |
"lengthMenu": "Show _MENU_",
|
|
|
313 |
"search": "Search:",
|
|
|
314 |
"zeroRecords": "No matching records found",
|
|
|
315 |
"paginate": {
|
|
|
316 |
"previous":"Prev",
|
|
|
317 |
"next": "Next",
|
|
|
318 |
"last": "Last",
|
|
|
319 |
"first": "First"
|
|
|
320 |
}
|
|
|
321 |
},
|
|
|
322 |
|
|
|
323 |
"footerCallback": function ( row, data, start, end, display ) {
|
|
|
324 |
var api = this.api(), data;
|
|
|
325 |
|
|
|
326 |
// Remove the formatting to get integer data for summation
|
|
|
327 |
var intVal = function ( i ) {
|
|
|
328 |
return typeof i === 'string' ?
|
|
|
329 |
i.replace(/[\$,]/g, '')*1 :
|
|
|
330 |
typeof i === 'number' ?
|
|
|
331 |
i : 0;
|
|
|
332 |
};
|
|
|
333 |
|
|
|
334 |
// Total over all pages
|
|
|
335 |
total = api
|
|
|
336 |
.column( 3 )
|
|
|
337 |
.data()
|
|
|
338 |
.reduce( function (a, b) {
|
|
|
339 |
return intVal(a) + intVal(b);
|
|
|
340 |
}, 0 );
|
|
|
341 |
|
|
|
342 |
// Total over this page
|
|
|
343 |
pageTotal = api
|
|
|
344 |
.column( 3, { page: 'current'} )
|
|
|
345 |
.data()
|
|
|
346 |
.reduce( function (a, b) {
|
|
|
347 |
return intVal(a) + intVal(b);
|
|
|
348 |
}, 0 );
|
|
|
349 |
|
|
|
350 |
// Update footer
|
|
|
351 |
$( api.column( 3 ).footer() ).html(
|
|
|
352 |
'$'+pageTotal +' ( $'+ total +' total)'
|
|
|
353 |
);
|
|
|
354 |
},
|
|
|
355 |
|
|
|
356 |
// Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
|
|
|
357 |
// setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
|
|
|
358 |
// So when dropdowns used the scrollable div should be removed.
|
|
|
359 |
//"dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
|
|
|
360 |
|
|
|
361 |
"bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
|
|
|
362 |
|
|
|
363 |
"lengthMenu": [
|
|
|
364 |
[6, 15, 20, -1],
|
|
|
365 |
[6, 15, 20, "All"] // change per page values here
|
|
|
366 |
],
|
|
|
367 |
// set the initial value
|
|
|
368 |
"pageLength": 6,
|
|
|
369 |
"columnDefs": [{ // set default column settings
|
|
|
370 |
'orderable': false,
|
|
|
371 |
'targets': [0]
|
|
|
372 |
}, {
|
|
|
373 |
"searchable": false,
|
|
|
374 |
"targets": [0]
|
|
|
375 |
}],
|
|
|
376 |
"order": [
|
|
|
377 |
[1, "asc"]
|
|
|
378 |
] // set first column as a default sort by asc
|
|
|
379 |
});
|
|
|
380 |
|
|
|
381 |
var tableWrapper = jQuery('#sample_5_wrapper');
|
|
|
382 |
|
|
|
383 |
table.find('.group-checkable').change(function () {
|
|
|
384 |
var set = jQuery(this).attr("data-set");
|
|
|
385 |
var checked = jQuery(this).is(":checked");
|
|
|
386 |
jQuery(set).each(function () {
|
|
|
387 |
if (checked) {
|
|
|
388 |
$(this).prop("checked", true);
|
|
|
389 |
} else {
|
|
|
390 |
$(this).prop("checked", false);
|
|
|
391 |
}
|
|
|
392 |
});
|
|
|
393 |
});
|
|
|
394 |
}
|
|
|
395 |
|
|
|
396 |
return {
|
|
|
397 |
|
|
|
398 |
//main function to initiate the module
|
|
|
399 |
init: function () {
|
|
|
400 |
if (!jQuery().dataTable) {
|
|
|
401 |
return;
|
|
|
402 |
}
|
|
|
403 |
|
|
|
404 |
initTable1();
|
|
|
405 |
initTable2();
|
|
|
406 |
initTable3();
|
|
|
407 |
initTable4();
|
|
|
408 |
initTable5();
|
|
|
409 |
}
|
|
|
410 |
|
|
|
411 |
};
|
|
|
412 |
|
|
|
413 |
}();
|
|
|
414 |
|
|
|
415 |
if (App.isAngularJsApp() === false) {
|
|
|
416 |
jQuery(document).ready(function() {
|
|
|
417 |
TableDatatablesManaged.init();
|
|
|
418 |
});
|
|
|
419 |
}
|