JSFiddle - React, Tailwind, and code Playground
by Joh_Christ
HTML
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Poppins&display=swap" rel="stylesheet">
<div>
<table id="example" class="cell-border" cellspacing="0">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th data-priority="1"></th>
</tr>
</thead>
</table>
CSS
table.display tbody tr:nth-child(odd) td {
background-color: rgb(242, 242, 242, .15);
}
table.display th,
td {
white-space: nowrap;
overflow: hidden;
}
;
JavaScript
$('document').ready(function() {
$.fn.DataTable.ext.pager.numbers_length = 5;
var results = [];
var url = "https://spreadsheets.google.com/feeds/list/1APUyDzibba211evfmIPQFmTOiwMkEUaL5Dqgc3U1o9U/od6/public/values?alt=json";
var jqxhr = $.getJSON(url, function() {
console.log("success");
})
.done(function(data) {
console.log("second success");
var entry = data.feed.entry;
$(entry).each(function() {
results.push([this.gsx$platz.$t, this.gsx$mannschaft.$t, this.gsx$spiele.$t, this.gsx$torverhältnis.$t, this.gsx$punkte.$t]);
});
var table = $('#example').DataTable({
data: results,
"responsive": true,
"autoWidth": false,
"lengthChange": false,
"paging": false,
"searching": false,
"bSort": false,
"fnRowCallback": function(nRow, aData) {
if (aData[0] == "1") {
$('td', nRow).css('background-color', 'rgba(0,0,139,.1)');
} else if (aData[0] == "2") {
$('td', nRow).css('background-color', 'rgba(0,0,139,.1)');
} else if (aData[0] == "3") {
$('td', nRow).css('background-color', 'rgba(0,0,139,.1)');
} else if (aData[0] == "4") {
$('td', nRow).css('background-color', 'rgba(0,0,139,.1)');
} else if (aData[0] == "5") {
$('td', nRow).css('background-color', 'rgba(141,198,63,.3)');
} else if (aData[0] == "6") {
$('td', nRow).css('background-color', 'rgba(141,198,63,.2)');
} else if (aData[0] == "16") {
$('td', nRow).css('background-color', 'rgba(255,215,0,.2)');
} else if (aData[0] == "17") {
$('td', nRow).css('background-color', 'rgba(169,0,39,.2)');
} else if (aData[0] == "18") {
$('td', nRow).css('background-color', 'rgba(169,0,39,.2)');
}
},
"bInfo": false,
"columnDefs": [
{
"targets": [0,...