Issue with stateSave on first load

Issue with stateSave on first load

kreynertsonkreynertson Posts: 2Questions: 2Answers: 0

I have a working DataTable in a Grails application that I want to store the sort order in. There is a "Save" button on the page, which submits back to the controller, and then renders the same page with the same DataTable. The stateSave works every time, except for the first time the Save button is hit after opening the application. If I close the application, and re-open it, choose a column to sort by, and hit "Save," the column being sorted by will be any one of the first four columns. If I change the column being sorted on a second time, and hit "Save" again, the sort order is correctly persisted. This is happening on Chrome, Firefox, and IE. Has anyone seen this or does anyone have information on stateSave that might help with debugging? My table is defined below:

var example = $("#example");
var table = example.DataTable({
"data": dataSet,
bFilter: true,
stateSave: true,
"searching": true,
"processing": true,
"serverSide": false,
"bPaginate": true,
"iDisplayLength": 25,
"bSortCellsTop" : true,
"lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
"columns": [
{ "name" : "Column 1" },
{ "name" : "Column 2" },
{ "name" : "Column 3" },
{ "name" : "Column 4" },
{ "name" : "Column 5" },
{ "name" : "Column 6" },
{ "name" : "Column 7" },
{ "name" : "Column 8" },
{ "name" : "Column 9" },
{ "name" : "Column 10" },
{ "name" : "Column 11" },
{ "name" : "Column 12" }
],
"columnDefs": [{"targets":[6,7,8,9,10], "orderable":false}],
"dom": '<"top"f<"dt-info"i><"dt-paginate"l>p<"clear">>rt<"bottom"<"dt-info"i><"dt-paginate"l>p<"clear">>',
tableTools: {
"sSwfPath": "<g:createLink controller="exampleController" action="exampleAction" absolute="false"/>/exampleFile",
"aButtons": [
]
},
"createdRow": function ( row, data, index ) {
$(row).attr('id', 'row_' + index);
},
"order" : [[ 4, "asc" ]]
});

This discussion has been closed.