/*************************************************************************************/ // -->Template Name: Bootstrap Press Admin // -->Author: Themedesigner // -->Email: niravjoshi87@gmail.com // -->File: datatable_api_init /*************************************************************************************/ //==================================================// // Add row // //==================================================// var t = $("#t_add_row").DataTable(); var counter = 1; $("#addRow").on("click", function () { t.row .add([ counter + ".1", counter + ".2", counter + ".3", counter + ".4", counter + ".5", ]) .draw(false); counter++; }); // Automatically add a first row of data $("#addRow").click(); //==================================================// // Individual column searching (select inputs) // //==================================================// $(".datatable-select-inputs").DataTable({ initComplete: function () { this.api() .columns() .every(function () { var column = this; var select = $( '' ) .appendTo($(column.footer()).empty()) .on("change", function () { var val = $.fn.dataTable.util.escapeRegex($(this).val()); column.search(val ? "^" + val + "$" : "", true, false).draw(); }); column .data() .unique() .sort() .each(function (d, j) { select.append('"); }); }); }, }); //==================================================// // Individual column searching (text inputs) // //==================================================// // Setup - add a text input to each footer cell $(".text-inputs-searching tfoot th").each(function () { var title = $(this).text(); $(this).html( '' ); }); // DataTable var tableSearching = $(".text-inputs-searching").DataTable(); // Apply the search tableSearching.columns().every(function () { var that = this; $("input", this.footer()).on("keyup change", function () { if (that.search() !== this.value) { that.search(this.value).draw(); } }); }); //==================================================// // Child rows (show extra / detailed information) // //==================================================// /* Formatting function for row details - modify as you need */ function format(d) { // `d` is the original data object for the row return ( '
Full name: | " + "" + d.name + " | " + "
Extension number: | " + "" + d.extn + " | " + "
Extra info: | " + "And any further details here (images etc)... | " + "