Odd Sorting Behaviour

Odd Sorting Behaviour

topherfangiotopherfangio Posts: 2Questions: 0Answers: 0
edited June 2010 in General
Hello all,

I've been using DataTables for about two months now, and it has really helped our application become more user friendly. Our clients love it! However, I've run into an interesting problem, and I couldn't seem to find out any information about it using the search available on this site. So, on to the problem:

I have enabled the default sorting on all of the columns in my table. This works really well except for the case of the first column which contains a person's name in the form of "Last, First". For some reason, its sorting based on the first name instead of the last name. Does anyone know why it is doing this and/or an easy way to change it?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Sounds very odd! DataTables should be using just string sorting for this kind of thing. Could you show us an example of the HTML you are using?

    Allan
  • topherfangiotopherfangio Posts: 2Questions: 0Answers: 0
    edited June 2010
    So, apparently I'm a moron. I sat down to write out an example to show you what was happening and I found my problem. As it turns out, my "name" column was actually a link and dataTables was treating it as a string instead of HTML. Adding the following to my javascript before I ran .dataTables fixed it:

    [code]
    jQuery.fn.dataTableExt.aTypes.push(
    function ( sData ) {
    return 'html';
    }
    );
    [/code]

    Thanks for the help, and sorry to have bothered you with such a simple question :-)

    Hope this saves someone else some trouble.

    Edit: For reference, I found the above information at http://www.datatables.net/plug-ins/type-detection under "HTML auto detection".
This discussion has been closed.