$(document).ready(function(){ applyDataTable5(); applyDataTable6(); }); function applyDataTable5() { var $fileName = "Pricing Proposal - "; $('#dataTable5 thead tr') //.clone(true) //.addClass('filters') //.appendTo('#dataTable5 thead'); //alert(tableId); var table = $('#dataTable5').DataTable({ orderCellsTop: true, //fixedHeader: true, bSort: false, initComplete: function () { var api = this.api(); // For each column api .columns() .eq(0) .each(function (colIdx) { //// Set the header cell to contain the input element //var cell = $('#dataTable5 .filters th').eq( // $(api.column(colIdx).header()).index() //); //var title = $(cell).text(); //$(cell).html(''); //' + title + ' // On every keypress in this input //$('input', $('#dataTable5 .filters th').eq($(api.column(colIdx).header()).index())) // .off('keyup change') // .on('keyup change', function (e) // { // e.stopPropagation(); // // Get the search value // $(this).attr('title', $(this).val()); // var regexr = '({search})'; //$(this).parents('th').find('select').val(); // var cursorPosition = this.selectionStart; // // Search the column for that value // api // .column(colIdx) // .search( // this.value != '' // ? regexr.replace('{search}', '(((' + this.value + ')))') // : '', // this.value != '', // this.value == '' // ) // .draw(); // $(this) // .focus()[0] // .setSelectionRange(cursorPosition, cursorPosition); // }); }); }, pageLength: -1, dom: 'Bfrtip', //dom: '<"dt-top-container"<"dt-center-in-div"B>r>t<"dt-filter-spacer"f>' lengthMenu: [ [ 10, 25, 50, -1 ], [ '10 rows', '25 rows', '50 rows', 'Show all' ] ], buttons: [ 'copy', 'print', {extend: 'csv', name: 'csv'}, {extend: 'excel', filename: $fileName}] }); }; function applyDataTable6() { var $fileName = "Detailed Pricing - "; $('#dataTable6 thead tr') // .clone(true) // .addClass('filters') // .appendTo('#dataTable6 thead'); //alert(tableId); var table = $('#dataTable6').DataTable({ orderCellsTop: true, colReorder: true, //fixedColumns: true, //fixedHeader: true, bSort: false, // initComplete: function () { // var api = this.api(); // // // For each column // api // .columns() // .eq(0) // .each(function (colIdx) { // // Set the header cell to contain the input element // var cell = $('#dataTable6 .filters th').eq( // $(api.column(colIdx).header()).index() // ); // var title = $(cell).text(); // $(cell).html(''); //' + title + ' // // // On every keypress in this input // $('input', $('#dataTable6 .filters th').eq($(api.column(colIdx).header()).index())) // .off('keyup change') // .on('keyup change', function (e) // { // e.stopPropagation(); // // // Get the search value // $(this).attr('title', $(this).val()); // var regexr = '({search})'; //$(this).parents('th').find('select').val(); // // var cursorPosition = this.selectionStart; // // Search the column for that value // api // .column(colIdx) // .search( // this.value != '' // ? regexr.replace('{search}', '(((' + this.value + ')))') // : '', // this.value != '', // this.value == '' // ) // .draw(); // // $(this) // .focus()[0] // .setSelectionRange(cursorPosition, cursorPosition); // }); // }); // }, pageLength: -1, dom: 'Bfrtip', //dom: '<"dt-top-container"<"dt-center-in-div"B>r>t<"dt-filter-spacer"f>' lengthMenu: [ [ 10, 25, 50, -1 ], [ '10 rows', '25 rows', '50 rows', 'Show all' ] ], buttons: [ 'copy', {extend: 'print', title: $fileName, orientation: 'landscape', pageSize: 'A4'}, {extend: 'csv', name: 'csv'}, {extend: 'excel', filename: $fileName} ] }); };