Sorting column by contents, not span title

Sorting column by contents, not span title

JoshEricksonJoshErickson Posts: 3Questions: 1Answers: 0

Hi guys,

In my table I am using <span title="some info">contents</span> as a way to allow me to hover over elements in the table to see a bit more info about them. Unfortunately, it sorts the column by what's in the title, and I would like it to sort it by the actual contents. Any ideas?

Thanks,
Josh

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,853Questions: 1Answers: 10,134 Site admin

    It shouldn't use the title content. Are you using 1.10.4? There was a bug in the old 1.9.4 release that might cause what you describe, but it is difficult to say without a link to a test case (as required in the forum rules :-) ).

    Allan

  • JoshEricksonJoshErickson Posts: 3Questions: 1Answers: 0

    Sorry :D. Here's an example: http://jsfiddle.net/HEDvf/2079/

    I'm using jquery 1.11.1 and datatables 1.10.4. So if you sort on values, you should see that it doesn't order them by the values displayed in the table. You can hover over those values to see the title contents, which is what it looks like it's sorting on.

    For example, 30.3 has a title that starts with 9.7...

  • allanallan Posts: 61,853Questions: 1Answers: 10,134 Site admin
    Answer ✓

    Got it - thanks. I think the issue is that there are new line characters in the HTML. If you replace them with &#10; then it works as expected: http://jsfiddle.net/HEDvf/2083/ .

    Is your HTML generated and can you add that? Although having said that, I think DataTables should cope with this. I'll take a look into what change is needed.

    Allan

  • JoshEricksonJoshErickson Posts: 3Questions: 1Answers: 0

    Thanks Allan! Yes, I'm generating the HTML so I was able to add that and it took care of the problem.

This discussion has been closed.