column.js (3176B)
1 var filterBy = function(tableType) { 2 $.fn.dataTableExt.afnFiltering.length = 0; 3 $.fn.dataTable.ext.search.push( 4 function( settings, data, dataIndex ) { 5 var type = data[1]; // use data for the Type column 6 7 if ( type == tableType || tableType=='All' ) 8 { 9 return true; 10 } 11 return false; 12 } 13 ); 14 } 15 16 $(document).ready(function() { 17 var activeObject; 18 var table = $('#column_table').DataTable( { 19 deferRender: true, 20 data: tableData, 21 columns: [ 22 { data: "tableName" }, 23 { data: "tableType" }, 24 { data: "name" }, 25 { data: "type" }, 26 { data: "length" }, 27 { data: "nullable" }, 28 { data: "autoUpdated" }, 29 { data: "defaultValue" }, 30 { data: "comments" } 31 ], 32 columnDefs: [ 33 { 34 targets: 0, 35 render: function ( data, type, row, meta ) { 36 return '<a href="tables/'+row.tableFileName+'.html" target="_top">'+data+'</a>'; 37 } 38 }, 39 { 40 targets: 2, 41 createdCell: function(td, cellData, rowData, row, col) { 42 if (rowData.keyTitle.length > 0) { 43 $(td).prop('title', rowData.keyTitle); 44 } 45 if (rowData.keyClass.length > 0) { 46 $(td).addClass(rowData.keyClass); 47 } 48 } 49 }, 50 { 51 targets: 5, 52 createdCell: function(td, cellData, rowData, row, col) { 53 if (cellData == '√') { 54 $(td).prop('title', "nullable"); 55 } 56 } 57 }, 58 { 59 targets: 6, 60 createdCell: function(td, cellData, rowData, row, col) { 61 if (cellData == '√') { 62 $(td).prop('title', "Automatically updated by the database"); 63 } 64 } 65 } 66 ], 67 lengthChange: false, 68 paging: config.pagination, 69 pageLength: 50, 70 autoWidth: true, 71 order: [[ 2, "asc" ]], 72 buttons: [ 73 { 74 text: 'All', 75 action: function ( e, dt, node, config ) { 76 filterBy('All'); 77 if (activeObject != null) { 78 activeObject.active(false); 79 } 80 table.draw(); 81 } 82 }, 83 { 84 text: 'Tables', 85 action: function ( e, dt, node, config ) { 86 filterBy('Table'); 87 if (activeObject != null) { 88 activeObject.active(false); 89 } 90 this.active( !this.active() ); 91 activeObject = this; 92 table.draw(); 93 } 94 }, 95 { 96 text: 'Views', 97 action: function ( e, dt, node, config ) { 98 filterBy('View'); 99 if (activeObject != null) { 100 activeObject.active(false); 101 } 102 this.active( !this.active() ); 103 activeObject = this; 104 table.draw(); 105 } 106 }, 107 { 108 extend: 'columnsToggle', 109 columns: '.toggle' 110 } 111 ] 112 113 } ); 114 115 //schemaSpy.js 116 dataTableExportButtons(table); 117 } );