Asc/Desc tooltip on sorting columns?

Asc/Desc tooltip on sorting columns?

gibb3hgibb3h Posts: 7Questions: 0Answers: 0
edited October 2009 in General
Hello again, I was wondering if there was some way that I could add hover tooltips to the column headers to display what direction the column will be sorted by when clicked, i.e. if it is currently sorted by ascending, the tooltip would say descending and vice-versa, is this possible?

Thanks in advance for your help :)

Replies

  • gibb3hgibb3h Posts: 7Questions: 0Answers: 0
    edited October 2009
    Never mind, I found a way to do it, here it is if you're insterested (or can think of a better way! :D)
    [code]
    $("#resultstab").dataTable({
    "bProcessing": true,
    "bPaginate": true,
    "bLengthChange": true,
    "bFilter": false,
    "bSort": true,
    "bInfo": true,
    "bAutoWidth": false,
    "sPaginationType": "full_numbers",
    "fnDrawCallback": function() {
    $('th').each(function(){
    if (($(this).hasClass('sorting')) || ($(this).hasClass('sorting_desc'))) {
    $(this).attr({title: 'Sort Ascending'});
    } else {
    $(this).attr({title: 'Sort Descending'});
    }
    });

    }
    });
    [/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi gibb3h,

    Good to hear you found a way to do it - looks like quite a reasonable way to me :-). Thanks for sharing your solution.

    Regards,
    Allan
  • noangelnoangel Posts: 2Questions: 0Answers: 0
    Just what I have been looking for, thank you for posting!
This discussion has been closed.