Capturing sort event on table heading

Capturing sort event on table heading

jocapcjocapc Posts: 45Questions: 0Answers: 0
edited May 2011 in General
Hi,

Is there any ellegant way to attach listener to the sort event on the heading cell - more elegant than
$("thead td").click(function() {} );

I'm using some sort of grouping and I put fixed sorting desc on grouped column and user can sort other columns but the grouped column will always be sorted first. However I have not hide this column and I would like to enable user to change asc/desc ordering of the grouping column, and I canot capture column sort event.

Example is on the http://jquery-datatables-row-grouping.googlecode.com/svn/trunk/letters.html third column is grouped by the first letter.
I have added function as a $.fn.dataTableExt.afnSortData function but this is called for each row (or I'm wrong)
fnSortListener also does not work for me because I do not have external element whhere I want to attach event handler I want to capture click on the exisitng table heading cell.

Thanks,
Jovan

Replies

  • allanallan Posts: 62,057Questions: 1Answers: 10,173 Site admin
    The way you have it at the moment is really the best way for now. In future there will be an event fired off, but that probably won't come until DataTables 2. There is a flag in the table's settings object which notes when the table is being sorted - but if you just want to know when a given column is sorted - then the listener you have is probably the best way.

    Allan
This discussion has been closed.