JSFiddle - React, Tailwind, and code Playground
by MrTest
JavaScript
$(document).ready(function() {
$('.table-data').each(function(index, table) {
$('.table-data tr td:last-child').addClass('last-td');
var RowsNumber = $(this).children('tbody').children('tr').length;
if (RowsNumber > 10 && $(this).hasClass('not-sortable')) {
$(this).dataTable({
"bSort": false,
"sPaginationType": "full_numbers",
"bStateSave": false,
"bRetrieve": true,
"aoColumns": [{
"sSortDataType": "natural"}]
});
}
else if (RowsNumber <= 10 && $(this).hasClass('not-sortable')) {
$(this).dataTable({
"bSort": false,
"bStateSave": false,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bRetrieve": true
});
}
else if (RowsNumber > 10) {
$(this).dataTable({
"sPaginationType": "full_numbers",
"bStateSave": false,
"bRetrieve": true
});
}
else {
$(this).dataTable({
"bSort": true,
"bStateSave": false,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bRetrieve": true
});
}
//Get first class of the table
var TableFirstClass = $(this).attr('class').split(' ')[0]
$(this).find("div[class*='_filter']").addClass(TableFirstClass + '_filter'); // search input
$(this).find("div[class*='_length']").addClass(TableFirstClass + '_length'); // rows count / slip by 10,20 etc..
$(this).find("div[class*='_info']").addClass(TableFirstClass + '_info'); // rows count
$(this).find("div[class*='_paginate']").addClass(TableFirstClass + '_paginate'); // pagination
//Pagination
...