table-datatables-fixedheader.js
5.94 KB
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
var TableDatatablesFixedHeader = function () {
var initTable1 = function () {
var table = $('#sample_1');
var fixedHeaderOffset = 0;
if (App.getViewPort().width < App.getResponsiveBreakpoint('md')) {
if ($('.page-header').hasClass('page-header-fixed-mobile')) {
fixedHeaderOffset = $('.page-header').outerHeight(true);
}
} else if ($('body').hasClass('page-header-menu-fixed')) { // admin 3 fixed header menu mode
fixedHeaderOffset = $('.page-header-menu').outerHeight(true);
} else if ($('body').hasClass('page-header-top-fixed')) { // admin 3 fixed header top mode
fixedHeaderOffset = $('.page-header-top').outerHeight(true);
} else if ($('.page-header').hasClass('navbar-fixed-top')) {
fixedHeaderOffset = $('.page-header').outerHeight(true);
} else if ($('body').hasClass('page-header-fixed')) {
fixedHeaderOffset = 64; // admin 5 fixed height
}
var oTable = table.dataTable({
// Internationalisation. For more info refer to http://datatables.net/manual/i18n
"language": {
"aria": {
"sortAscending": ": activate to sort column ascending",
"sortDescending": ": activate to sort column descending"
},
"emptyTable": "No data available in table",
"info": "Showing _START_ to _END_ of _TOTAL_ entries",
"infoEmpty": "No entries found",
"infoFiltered": "(filtered1 from _MAX_ total entries)",
"lengthMenu": "_MENU_ entries",
"search": "Search:",
"zeroRecords": "No matching records found"
},
// Or you can use remote translation file
//"language": {
// url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
//},
// setup rowreorder extension: http://datatables.net/extensions/fixedheader/
fixedHeader: {
header: true,
headerOffset: fixedHeaderOffset
},
"order": [
[0, 'asc']
],
"lengthMenu": [
[5, 10, 15, 20, -1],
[5, 10, 15, 20, "All"] // change per page values here
],
// set the initial value
"pageLength": 20,
// Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
// setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
// So when dropdowns used the scrollable div should be removed.
//"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>>",
});
}
var initTable2 = function () {
var table = $('#sample_2');
var fixedHeaderOffset = 0;
if (App.getViewPort().width < App.getResponsiveBreakpoint('md')) {
if ($('.page-header').hasClass('page-header-fixed-mobile')) {
fixedHeaderOffset = $('.page-header').outerHeight(true);
}
} else if ($('.page-header').hasClass('navbar-fixed-top')) {
fixedHeaderOffset = $('.page-header').outerHeight(true);
} else if ($('body').hasClass('page-header-fixed')) {
fixedHeaderOffset = 64; // admin 5 fixed height
}
var oTable = table.dataTable({
// Internationalisation. For more info refer to http://datatables.net/manual/i18n
"language": {
"aria": {
"sortAscending": ": activate to sort column ascending",
"sortDescending": ": activate to sort column descending"
},
"emptyTable": "No data available in table",
"info": "Showing _START_ to _END_ of _TOTAL_ entries",
"infoEmpty": "No entries found",
"infoFiltered": "(filtered1 from _MAX_ total entries)",
"lengthMenu": "_MENU_ entries",
"search": "Search:",
"zeroRecords": "No matching records found"
},
// Or you can use remote translation file
//"language": {
// url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
//},
// setup rowreorder extension: http://datatables.net/extensions/fixedheader/
fixedHeader: {
header: true,
footer: true,
headerOffset: fixedHeaderOffset
},
"order": [
[0, 'asc']
],
"lengthMenu": [
[5, 10, 15, 30, -1],
[5, 10, 15, 30, "All"] // change per page values here
],
// set the initial value
"pageLength": 30,
// Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
// setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
// So when dropdowns used the scrollable div should be removed.
//"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>>",
});
}
return {
//main function to initiate the module
init: function () {
if (!jQuery().dataTable) {
return;
}
initTable1();
initTable2();
}
};
}();
jQuery(document).ready(function() {
TableDatatablesFixedHeader.init();
});