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
/* ------------------------------------------------------------------------------
*
* # Invoice archive
*
* Specific JS code additions for invoice_archive.html page
*
* Version: 1.0
* Latest update: Aug 1, 2015
*
* ---------------------------------------------------------------------------- */
$(function() {
// Table setup
// ------------------------------
// Initialize
$('.invoice-archive').DataTable({
autoWidth: false,
columnDefs: [
{
width: '30px',
targets: 0
},
{
visible: false,
targets: 1
},
{
orderable: false,
width: '100px',
targets: 7
},
{
width: '15%',
targets: [4, 5]
},
{
width: '15%',
targets: 6
},
{
width: '15%',
targets: 3
}
],
order: [[ 0, 'desc' ]],
dom: '<"datatable-header"fl><"datatable-scroll-lg"t><"datatable-footer"ip>',
language: {
search: '<span>Filter:</span> _INPUT_',
searchPlaceholder: 'Type to filter...',
lengthMenu: '<span>Show:</span> _MENU_',
paginate: { 'first': 'First', 'last': 'Last', 'next': '→', 'previous': '←' }
},
lengthMenu: [ 25, 50, 75, 100 ],
displayLength: 25,
drawCallback: function ( settings ) {
var api = this.api();
var rows = api.rows( {page:'current'} ).nodes();
var last=null;
api.column(1, {page:'current'} ).data().each( function ( group, i ) {
if ( last !== group ) {
$(rows).eq( i ).before(
'<tr class="active border-double"><td colspan="8" class="text-semibold">'+group+'</td></tr>'
);
last = group;
}
});
$('.select').select2({
width: '150px',
minimumResultsForSearch: Infinity
});
$(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').addClass('dropup');
},
preDrawCallback: function(settings) {
$(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').removeClass('dropup');
$('.select').select2().select2('destroy');
}
});
// External table additions
// ------------------------------
// Enable Select2 select for the length option
$('.dataTables_length select').select2({
minimumResultsForSearch: Infinity,
width: 'auto'
});
});