| 9 |
lars |
1 |
var TableDatatablesFixedHeader = function () {
|
|
|
2 |
|
|
|
3 |
var initTable1 = function () {
|
|
|
4 |
var table = $('#sample_1');
|
|
|
5 |
|
|
|
6 |
var fixedHeaderOffset = 0;
|
|
|
7 |
if (App.getViewPort().width < App.getResponsiveBreakpoint('md')) {
|
|
|
8 |
if ($('.page-header').hasClass('page-header-fixed-mobile')) {
|
|
|
9 |
fixedHeaderOffset = $('.page-header').outerHeight(true);
|
|
|
10 |
}
|
|
|
11 |
} else if ($('.page-header').hasClass('navbar-fixed-top')) {
|
|
|
12 |
fixedHeaderOffset = $('.page-header').outerHeight(true);
|
|
|
13 |
}
|
|
|
14 |
|
|
|
15 |
var oTable = table.dataTable({
|
|
|
16 |
|
|
|
17 |
// Internationalisation. For more info refer to http://datatables.net/manual/i18n
|
|
|
18 |
"language": {
|
|
|
19 |
"aria": {
|
|
|
20 |
"sortAscending": ": activate to sort column ascending",
|
|
|
21 |
"sortDescending": ": activate to sort column descending"
|
|
|
22 |
},
|
|
|
23 |
"emptyTable": "No data available in table",
|
|
|
24 |
"info": "Showing _START_ to _END_ of _TOTAL_ entries",
|
|
|
25 |
"infoEmpty": "No entries found",
|
|
|
26 |
"infoFiltered": "(filtered1 from _MAX_ total entries)",
|
|
|
27 |
"lengthMenu": "_MENU_ entries",
|
|
|
28 |
"search": "Search:",
|
|
|
29 |
"zeroRecords": "No matching records found"
|
|
|
30 |
},
|
|
|
31 |
|
|
|
32 |
// Or you can use remote translation file
|
|
|
33 |
//"language": {
|
|
|
34 |
// url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
|
|
|
35 |
//},
|
|
|
36 |
|
|
|
37 |
// setup rowreorder extension: http://datatables.net/extensions/fixedheader/
|
|
|
38 |
fixedHeader: {
|
|
|
39 |
header: true,
|
|
|
40 |
headerOffset: fixedHeaderOffset
|
|
|
41 |
},
|
|
|
42 |
|
|
|
43 |
"order": [
|
|
|
44 |
[0, 'asc']
|
|
|
45 |
],
|
|
|
46 |
|
|
|
47 |
"lengthMenu": [
|
|
|
48 |
[5, 10, 15, 20, -1],
|
|
|
49 |
[5, 10, 15, 20, "All"] // change per page values here
|
|
|
50 |
],
|
|
|
51 |
// set the initial value
|
|
|
52 |
"pageLength": 20,
|
|
|
53 |
|
|
|
54 |
// Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
|
|
|
55 |
// setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
|
|
|
56 |
// So when dropdowns used the scrollable div should be removed.
|
|
|
57 |
//"dom": "<'row' <'col-md-12'T>><'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>>",
|
|
|
58 |
});
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
var initTable2 = function () {
|
|
|
62 |
var table = $('#sample_2');
|
|
|
63 |
|
|
|
64 |
var fixedHeaderOffset = 0;
|
|
|
65 |
if (App.getViewPort().width < App.getResponsiveBreakpoint('md')) {
|
|
|
66 |
if ($('.page-header').hasClass('page-header-fixed-mobile')) {
|
|
|
67 |
fixedHeaderOffset = $('.page-header').outerHeight(true);
|
|
|
68 |
}
|
|
|
69 |
} else if ($('.page-header').hasClass('navbar-fixed-top')) {
|
|
|
70 |
fixedHeaderOffset = $('.page-header').outerHeight(true);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
var oTable = table.dataTable({
|
|
|
74 |
|
|
|
75 |
// Internationalisation. For more info refer to http://datatables.net/manual/i18n
|
|
|
76 |
"language": {
|
|
|
77 |
"aria": {
|
|
|
78 |
"sortAscending": ": activate to sort column ascending",
|
|
|
79 |
"sortDescending": ": activate to sort column descending"
|
|
|
80 |
},
|
|
|
81 |
"emptyTable": "No data available in table",
|
|
|
82 |
"info": "Showing _START_ to _END_ of _TOTAL_ entries",
|
|
|
83 |
"infoEmpty": "No entries found",
|
|
|
84 |
"infoFiltered": "(filtered1 from _MAX_ total entries)",
|
|
|
85 |
"lengthMenu": "_MENU_ entries",
|
|
|
86 |
"search": "Search:",
|
|
|
87 |
"zeroRecords": "No matching records found"
|
|
|
88 |
},
|
|
|
89 |
|
|
|
90 |
// Or you can use remote translation file
|
|
|
91 |
//"language": {
|
|
|
92 |
// url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
|
|
|
93 |
//},
|
|
|
94 |
|
|
|
95 |
// setup rowreorder extension: http://datatables.net/extensions/fixedheader/
|
|
|
96 |
fixedHeader: {
|
|
|
97 |
header: true,
|
|
|
98 |
footer: true,
|
|
|
99 |
headerOffset: fixedHeaderOffset
|
|
|
100 |
},
|
|
|
101 |
|
|
|
102 |
"order": [
|
|
|
103 |
[0, 'asc']
|
|
|
104 |
],
|
|
|
105 |
|
|
|
106 |
"lengthMenu": [
|
|
|
107 |
[5, 10, 15, 30, -1],
|
|
|
108 |
[5, 10, 15, 30, "All"] // change per page values here
|
|
|
109 |
],
|
|
|
110 |
// set the initial value
|
|
|
111 |
"pageLength": 30,
|
|
|
112 |
|
|
|
113 |
// Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
|
|
|
114 |
// setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
|
|
|
115 |
// So when dropdowns used the scrollable div should be removed.
|
|
|
116 |
//"dom": "<'row' <'col-md-12'T>><'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>>",
|
|
|
117 |
});
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
return {
|
|
|
121 |
|
|
|
122 |
//main function to initiate the module
|
|
|
123 |
init: function () {
|
|
|
124 |
|
|
|
125 |
if (!jQuery().dataTable) {
|
|
|
126 |
return;
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
initTable1();
|
|
|
130 |
initTable2();
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
};
|
|
|
134 |
|
|
|
135 |
}();
|
|
|
136 |
|
|
|
137 |
jQuery(document).ready(function() {
|
|
|
138 |
TableDatatablesFixedHeader.init();
|
|
|
139 |
});
|