Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting current sorted column in DataTable

Tags:

datatables

I remember once I used some API to get table's sorted column info but I couldn't find now. I want to find which column currently is used for sorted and in which order? Since I am using both legacy and new DataTable in different project in different company I will appreciate if some one can provide PAI for both version.

like image 880
αƞjiβ Avatar asked Feb 24 '15 17:02

αƞjiβ


1 Answers

Assuming your table has an id of mytable

var sortedCol = $('#mytable').dataTable().fnSettings().aaSorting[0][0];
var sortedDir = $('#mytable').dataTable().fnSettings().aaSorting[0][1];
like image 118
markpsmith Avatar answered Oct 15 '22 05:10

markpsmith