Save/ Load sorting parameters(columnId, sortdirection) using database

Save/ Load sorting parameters(columnId, sortdirection) using database

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

Hello,
i'am new and i use datatables plug-in in my application.
I have issue with create method to save Sort information from Grid into database.
Idea is that, when i change colum ordering (drag and drop) i save this column configuration in database and this function worked fine. I use parameter:

"oColReorder": {
"fnReorderCallback": function () {
var columns = fnReorderCallback(Grid.fnSettings().aoColumns);
},
"aiOrder":ColOrder
},

Function fnReorderCallback is:

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

$.ajax({
    url: ColReorderUrl,
    data: "{ cols : '" + JSON.stringify(cols) + "'}",
    type: "POST",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: something
});

}

Next i create default sorting column when user don't have set order settings in database:

"aaSorting": [[0, "desc"]] -> this also worked fine.

My question is how i can create function to read sorting values from grid when i click on column arrow?
I try add to function fnReorderCallback two parameters(columnId and sort direction when i click on <th> name on Grid. But this solution is not good, because i save information about columnId and sort direction only when i change column ordering. I would like to create something better.

Thanks for help.
Regards
Matys

This discussion has been closed.