/*========================================================================================= File Name: datatable-advanced.js Description: Advanced Datatable ---------------------------------------------------------------------------------------- Item Name: Modern Admin - Clean Bootstrap 4 Dashboard HTML Template Version: 1.0 Author: PIXINVENT Author URL: http://www.themeforest.net/user/pixinvent ==========================================================================================*/ $(document).ready(function() { /*************************************** * js of dom jQuery events * ***************************************/ var eventsTable = $('.dom-jQuery-events').DataTable(); $('.dom-jQuery-events tbody').on('click', 'tr', function() { var data = table.row(this).data(); alert('You clicked on ' + data[0] + '\'s row'); }); /*************************************** * js of column rendering * ***************************************/ $('.column-rendering').DataTable({ "columnDefs": [{ // The `data` parameter refers to the data for the cell (defined by the // `data` option, which defaults to the column being worked with, in // this case `data: 0`. "render": function(data, type, row) { return data + ' (' + row[3] + ')'; }, "targets": 0 }, { "visible": false, "targets": [3] }] }); /****************************************************** * js of multiple table control elements * ******************************************************/ $('.multiple-control-elements').DataTable({ "dom": '<"top"iflp<"clear">>rt<"bottom"iflp<"clear">>' }); /************************************************************* * js of Complex headers with column visibility * *************************************************************/ $('.column-visibility').DataTable({ "columnDefs": [{ "visible": false, "targets": -1 }] }); /************************************ * js of Language file * ************************************/ $('.language-file').DataTable({ "language": { "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json" } }); /*************************************** * js of Setting defaults * ***************************************/ var defaults = { "searching": false, "ordering": false }; $('.setting-defaults').dataTable($.extend(true, {}, defaults, {})); /******************************************* * js of Row created callback * *******************************************/ $('.created-callback').DataTable({ "createdRow": function(row, data, index) { if (data[5].replace(/[\$,]/g, '') * 1 > 150000) { $('td', row).eq(5).addClass('highlight'); } } }); /******************************************** * js of Order by the grouping * ********************************************/ var groupingTable = $('.row-grouping').DataTable({ "columnDefs": [{ "visible": false, "targets": 2 }], "order": [ [2, 'asc'] ], "displayLength": 25, "drawCallback": function(settings) { var api = this.api(); var rows = api.rows({ page: 'current' }).nodes(); var last = null; api.column(2, { page: 'current' }).data().each(function(group, i) { if (last !== group) { $(rows).eq(i).before( '