JSFiddle - React, Tailwind, and code Playground
HTML
<head>
<link rel= "stylesheet" type= "text/css" href= "https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<link rel= "stylesheet" type= "text/css" href= "https://cdn.datatables.net/colreorder/1.5.4/css/colReorder.dataTables.min.css">
<link rel= "stylesheet" type= "text/css" href= "https://cdn.datatables.net/buttons/1.6.3/css/buttons.dataTables.min.css">
<script src="https://code.jquery.com/jquery-1.10.0.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/colreorder/1.5.4/js/dataTables.colReorder.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.6.3/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.5.6/js/buttons.colVis.min.js"></script>
</head>
<table id="example" class="display" style="width:100%"></table>
JavaScript
function dataTableRender(tableId) {
$(".tableActions").empty();
type = "";
$.extend($.fn.dataTableExt.oSort, {
"turkish-numeric-comma-pre": function (a) {
var text = a.trim().replace(/\./g, "").replace(",", "."); // Türkçe sayı formatına çevir
if (text === "<a>N/A</a>") { // Eğer "N/A" ise negatif sınırsız değer olarak döndür
return Number.NEGATIVE_INFINITY;
}
if (text === "<a></a>") {
return Number.NEGATIVE_INFINITY;
}
// Negatif değeri sıfıra çevirme
if (text.charAt(0) === '-') {
text = "-0" + text.substring(1);
}
var x = parseFloat(text);
return x;
},
"turkish-numeric-comma-asc": function (a, b) {
if (isNaN(a) && isNaN(b)) { return 0; }
if (isNaN(a)) { return -1; }
if (isNaN(b)) { return 1; }
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"turkish-numeric-comma-desc": function (a, b) {
if (isNaN(a) && isNaN(b)) { return 0; }
if (isNaN(a)) { return -1; }
if (isNaN(b)) { return 1; }
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
});
var codeListTable = $('#' + tableId).DataTable({
stateSave: true,
colReorder: {
fixedColumnsLeft: 4,
fixedColumnsRight: 1
},
fixedColumns: {
left: 2
},
stateSaveCallback: function (settings, data) {
$("#" + tableId).parent().addClass("scrollbar-custom");
...