-
Notifications
You must be signed in to change notification settings - Fork 0
/
column.js
117 lines (113 loc) · 3.09 KB
/
column.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
var filterBy = function(tableType) {
$.fn.dataTableExt.afnFiltering.length = 0;
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var type = data[1]; // use data for the Type column
if ( type == tableType || tableType=='All' )
{
return true;
}
return false;
}
);
}
$(document).ready(function() {
var activeObject;
var table = $('#column_table').DataTable( {
deferRender: true,
data: tableData,
columns: [
{ data: "tableName" },
{ data: "tableType" },
{ data: "name" },
{ data: "type" },
{ data: "length" },
{ data: "nullable" },
{ data: "autoUpdated" },
{ data: "defaultValue" },
{ data: "comments" }
],
columnDefs: [
{
targets: 0,
render: function ( data, type, row, meta ) {
return '<a href="tables/'+data+'.html" target="_top">'+data+'</a>';
}
},
{
targets: 2,
createdCell: function(td, cellData, rowData, row, col) {
if (rowData.keyTitle.length > 0) {
$(td).prop('title', rowData.keyTitle);
}
if (rowData.keyClass.length > 0) {
$(td).addClass(rowData.keyClass);
}
}
},
{
targets: 5,
createdCell: function(td, cellData, rowData, row, col) {
if (cellData == '√') {
$(td).prop('title', "nullable");
}
}
},
{
targets: 6,
createdCell: function(td, cellData, rowData, row, col) {
if (cellData == '√') {
$(td).prop('title', "Automatically updated by the database");
}
}
}
],
lengthChange: false,
paging: config.pagination,
pageLength: 50,
autoWidth: true,
order: [[ 2, "asc" ]],
buttons: [
{
text: 'All',
action: function ( e, dt, node, config ) {
filterBy('All');
if (activeObject != null) {
activeObject.active(false);
}
table.draw();
}
},
{
text: 'Tables',
action: function ( e, dt, node, config ) {
filterBy('Table');
if (activeObject != null) {
activeObject.active(false);
}
this.active( !this.active() );
activeObject = this;
table.draw();
}
},
{
text: 'Views',
action: function ( e, dt, node, config ) {
filterBy('View');
if (activeObject != null) {
activeObject.active(false);
}
this.active( !this.active() );
activeObject = this;
table.draw();
}
},
{
extend: 'columnsToggle',
columns: '.toggle'
}
]
} );
//schemaSpy.js
dataTableExportButtons(table);
} );