-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
62 lines (55 loc) · 1.45 KB
/
index.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
function createTable(tableData, callback) {
var table = $('table#jquery-table');
table.empty();
var header_columns = ["Header_1", "Header_2", "Header_3", "B", "C"];
var thead_tr = $('<tr>');
$.each(header_columns, function(x, hcol) {
$('<td>').text(hcol).appendTo(thead_tr);
});
table.append( $('<thead>').append(thead_tr) );
var tbody = $('<tbody>');
$.each(tableData.data, function(x, row) {
var tr = $('<tr>');
$.each(row, function(y, col) {
tr.append( $('<td>').text(col) );
});
tbody.append(tr);
});
table.append(tbody);
callback();
}
function TableSort() {
$("#jquery-table").tablesorter({
theme: 'blue',
widthFixed: true,
widgets: ['zebra', 'stickyHeaders', 'filter'],
showProcessing: true,
widgetOptions: {
filter_formatter: {
1: function($cell, indx) {
console.log("1 tablesorter.filterFormatter.select2 start");
return $.tablesorter.filterFormatter.select2($cell, indx, {
match: false
});
},
2: function($cell, indx) {
console.log("2 tablesorter.filterFormatter.select2 start");
return $.tablesorter.filterFormatter.select2($cell, indx, {
match: false
});
},
}
}
});
console.log("tablesorter finished");
}
Papa.parse('demo.csv', {
download: true,
header: true,
// quoteChar: '"',
complete: function(results) {
// console.log(results.meta.fields);
console.log("Parsing complete:", results.data);
createTable(results, TableSort);
}
});