Column Order Direction Always "asc" when ordering by second column - Server Side Rendering
Column Order Direction Always "asc" when ordering by second column - Server Side Rendering
Hey, I am using Datatables 1.10.21 and Datatables RowsGroup v1.0.0 with Server-side rendering.
FRONTEND: I am calling server-side URL with AJAX like this...
table= $(table).DataTable({
"processing": true,
"serverSide": true,
"aaSorting": [[0, "desc"]],
//"order": [[0, "desc"]],
"ajax": {
"url": config.procurements.getProcurementsURL,
"type": "POST",
"datatype": "json",
"orderMulti": false,
"searchable": true,
"orderable": true,
"sortable": true,
"lengthChange": true,
"scrollCollapse": false,
"data": function (d) {
d.CustomFilter = $('#Filter_CustomFilter').val();
d.FinalControlFilter = document.getElementById('Filter_FinalControlFilterBool').checked == false ? 0 : 1;
d.ProdAlumColorFilter = $('#Filter_ProdAlumColorFilter').val();
},
},
"rowsGroup": [
0,
1,
2,
12
],
});
new $.fn.dataTable.FixedHeader(table);
}
BACKEND: And my SERVER SIDE method is...
public ActionResult GenerateProcurements(){
int startRec = Convert.ToInt32(Request.Form.GetValues("start")[0]);
int pageSize = Convert.ToInt32(Request.Form.GetValues("length")[0]);
int customFilterType = Convert.ToInt32(Request.Form.GetValues("CustomFilter")[0]);
int alumColorFilter = Convert.ToInt32(Request.Form.GetValues("ProdAlumColorFilter")[0]);
int finalControlFilter = Convert.ToInt32(Request.Form.GetValues("FinalControlFilter")[0]);
string search = Request.Form.GetValues("search[value]")[0];
string draw = Request.Form.GetValues("draw")[0];
string order = Request.Form.GetValues("order[0][column]")[0];
string orderDir = Request.Form.GetValues("order[0][dir]")[0];
}
If I select Column 0 order I get the correct values for 'order' and 'orderDir'. When I Select Column 1 order it shows server side code collect the correct 'order' value (e.g. "1"), but 'order' is always equal to "asc".
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Replies
I'm not seeing that happen in this example I'm afraid. Can you give me a link to a test case showing the issue please.
Thanks,
Allan
I am using Row Grouping plugin and I think that is a problem. If I use server-side processing without row grouping it works fine.
Two things:
ajax
option. They need to be moved outside at the same level as lines 2-4. Also searchable, orderable and sortable aren't valid options. They are options applied to columns. See thecolumns.orderable
andcolumns.searchable
for more details.Kevin
IIRC the rowsGroup plugin forces the column oder to
asc
in order to build the groups. You can confirm this with the developer or by looking at the code.Kevin
I realized that double-click on the column sort option (when "ASC" is active) send order="DESC" on the server-side.
I will try to contact the plugin author for additional info.
Thank you so much.