Default Table Order

Default Table Order

kiwiskiwis Posts: 15Questions: 10Answers: 0
edited September 18 in Free community support

I'm loading my table content via a fetch query below.

My JSON data is in order and if I console log this I get this most recent rows first and oldest last.

My table however shows it the reverse way, oldest first.

Is there some auto sorting occurring? How can I disable this but then also allow sorting if a user wants it?

 var s = $('#myDataTable').DataTable();
     fetch('getMyData.php').then(function(response) {
             return response.json().then(function(data) {
                 for(var i = 0; i < data.length; i++) {
                     var obj = data[i];
                    var rowHtml = $('#tableRow').html()
                        .replace('{{Year}}',  obj.Year )
                        .replace('{{Title}}', obj.Label )

                document.getElementById("tableContainer").style.display = 'block';


  • colincolin Posts: 12,657Questions: 0Answers: 2,163

    You probably just want to set the initial order with order, choosing the opposite of 'asc' or 'desc' as to the default,


Sign In or Register to comment.