-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfootable-init.js
94 lines (72 loc) · 2.86 KB
/
footable-init.js
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
$(window).on('load', function() {
// Row Toggler
// -----------------------------------------------------------------
$('#demo-foo-row-toggler').footable();
// Accordion
// -----------------------------------------------------------------
$('#demo-foo-accordion').footable().on('footable_row_expanded', function(e) {
$('#demo-foo-accordion tbody tr.footable-detail-show').not(e.row).each(function() {
$('#demo-foo-accordion').data('footable').toggleDetail(this);
});
});
// Pagination
// -----------------------------------------------------------------
$('#demo-foo-pagination').footable();
$('#demo-show-entries').change(function (e) {
e.preventDefault();
var pageSize = $(this).val();
$('#demo-foo-pagination').data('page-size', pageSize);
$('#demo-foo-pagination').trigger('footable_initialized');
});
// Filtering
// -----------------------------------------------------------------
var filtering = $('#demo-foo-filtering');
filtering.footable().on('footable_filtering', function (e) {
var selected = $('#demo-foo-filter-status').find(':selected').val();
e.filter += (e.filter && e.filter.length > 0) ? ' ' + selected : selected;
e.clear = !e.filter;
});
// Filter status
$('#demo-foo-filter-status').change(function (e) {
e.preventDefault();
filtering.trigger('footable_filter', {filter: $(this).val()});
});
// Search input
$('#demo-foo-search').on('input', function (e) {
e.preventDefault();
filtering.trigger('footable_filter', {filter: $(this).val()});
});
// Search input
$('#demo-input-search2').on('input', function (e) {
e.preventDefault();
addrow.trigger('footable_filter', {filter: $(this).val()});
});
// Add & Remove Row
var addrow = $('#demo-foo-addrow');
addrow.footable().on('click', '.delete-row-btn', function() {
//get the footable object
var footable = addrow.data('footable');
//get the row we are wanting to delete
var row = $(this).parents('tr:first');
//delete the row
footable.removeRow(row);
});
var addrow = $('#demo-foo-addrow2');
addrow.footable().on('click', '.delete-row-btn', function() {
//get the footable object
var footable = addrow.data('footable');
//get the row we are wanting to delete
var row = $(this).parents('tr:first');
//delete the row
footable.removeRow(row);
});
// Add Row Button
$('#demo-btn-addrow').click(function() {
//get the footable object
var footable = addrow.data('footable');
//build up the row we are wanting to add
var newRow = '<tr><td>thome</td><td>Woldt</td><td>Airline Transport Pilot</td><td>3 Oct 2016</td><td><span class="label label-table label-success">Active</span></td><td><button type="button" class="btn btn-sm btn-icon btn-pure btn-outline delete-row-btn" data-toggle="tooltip" data-original-title="Delete"><i class="ti-close" aria-hidden="true"></i></button></td></tr>';
//add it
footable.appendRow(newRow);
});
});