Reputation: 2315
I manage to display the Datatable right from ajax. But the only problem is. The table is not show the data as it is.
Data from report_ajax.php
[json]
{"data":[
["22:00:00","16dee076f62ce35f3b64ee14d8fec748","0"],
["22:15:00","8aa57813201bc78849baa56eafb0f04c","0"],
["22:15:00","17b6bd8adfc11c4efe571edacc528d58","0"],
["22:15:00","a4048f751f4f9e4b2779aa52dfcf5903","0"],
["22:30:00","c39624dca09de650ae28b4e68f09f7a1","0"],
["22:45:00","3a471c7b5204ae0d6fd510006c67b89b","0"],
["23:00:00","202dc747da31af7b70a714823df35fbc","0"],
["23:25:00","71ad04376d1a2b6e0d5fbb88d2efcafe","0"],
["23:30:00","b87c8dc8789fdb0b947b8bfb39efd88c","0"],
["23:45:00","0f1cab9da99f3da84efd62cee0d447e8","0"],
["00:05:00","6a601ce30d73cb3525cae8269e658140","0"],
["00:15:00","99bf53fb6c458d23060846a7478c23ef","0"],
["00:30:00","c9e42098c79fadbcfeb8f2137b5d6b27","0"],
["00:45:00","ba87e8493eed4768384123e1e242b2a7","0"],
["00:50:00","9d55061b4af7116732260c6c3f505b9a","0"]
.
.
.
]}
As you see, the 1st array is time
. I expect datatable
will display with this order. But as a result, it sort my data and runs from 00:00
to 23:45
pretty well.
This is my jquery:
var table=$('#dataTable').DataTable( {
ajax: "report_ajax.php",
//stateSave: true,
"pageLength": 25,
});
I want datatable display exactly as the data sent to. What should I fix?
Upvotes: 0
Views: 35
Reputation: 997
You just need to add a parameter and it will not sort the data in the initial list
"order": []
So your code should be
var table=$('#dataTable').DataTable( {
ajax: "report_ajax.php",
//stateSave: true,
"pageLength": 25,
"order": []
});
Upvotes: 1