I have a very simple HTML table that renders in the order that I want it to without any call to 'DataTable()' in the '$document ready()' function call.
Old output
<table id="mytable" class="display">
<thead>
<tr>
<th>Title</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Item1</td>
<td>1</td>
</tr>
<tr>
<td>Item2</td>
<td>2</td>
</tr>
<tr>
<td>Item3</td>
<td>3</td>
</tr>
<tr>
<td>Item4</td>
<td>4</td>
</tr>
</tbody>
</table>
However, after calling 'DataTable()' the ordering is seemingly random.
New output
<table id="mytable" class="display">
<thead>
<tr>
<th>Title</th>
</tr>
<tr>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Item4</td>
<td>4</td>
</tr>
<tr>
<td>Item3</td>
<td>3</td>
</tr>
<tr>
<td>Item1</td>
<td>1</td>
</tr>
<tr>
<td>Item2</td>
<td>2</td>
</tr>
</tbody>
</table>
DataTable call
<script>
$(document).ready(function() {
$('#mytable').DataTable({
"stripeClasses": [],
"pageLength": 25,
"rowReorder": {
enable: false
}
});
});
</script>
Why does DataTables do this? Is there anyway I can preserve my ordering (1,2,3,4)? I've taken a look at the documentation options, specifically Row ReOrder, but to no avail.
I realize I should be calling DataTable with ajax and all that jazz, but that is a little beyond what I'd like to be doing right now. I'd just like to square this away first.