Issue with Reload DataTables

Issue with Reload DataTables

matysmatys Posts: 3Questions: 3Answers: 0
edited August 2014 in Free community support

Hello,
i have a problem with dataTables when i try to save sort information in database.
When i click on th header in Grid i choose columnId by sort and direction sort of column.
Issue is that:
Click on th header=> save in db => reload Grid. Always i save previous values in db.
I wanna have this oreder : Click on th header => reload Grid => save in db actually sort direction and column
This my function code:

$("#example th").click(function () {

var cols = new Array();

var columns = Grid.fnSettings().aoColumns;

for (var i = 0; i < columns.length; i++) {
    cols.push({ OriginalIndex: columns[i]._ColReorder_iOrigCol, Width: columns[i].sWidth, Visible: columns[i].bVisible });
}

var sortDirection = $("#example").dataTable().fnSettings().aaSorting[0][1];
var columnId = $("#example").dataTable().fnSettings().aaSorting[0][0];

$.ajax({
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    type: "POST",
    url: that.UserColumnSortSettingsUrl,
    data: "{ColumnId: '" + columnId + "', SortDirection: '" + sortDirection + "', cols: '" + JSON.stringify(cols) + "'}",      
});

});

This discussion has been closed.