1

I have a column that was pure text and the sorting worked fine but when I change the column data to HTML regular links, the sorting seems quite random and broken. I couldn't find any other documentation on this issue on the site.

http://www.datatables.net/usage/features

Any suggestions?

4 Answers 4

5

Use sSortDataType and sType (with value html) to notate the column as containing HTML and remove it prior to sorting. Docs on the Columns page.

Sign up to request clarification or add additional context in comments.

2 Comments

What is sSortDataType supposed to be set to? This doesn't work: { 'sSortDataType': 'dom-text', 'sType': 'html' }
@consolibyte I believe these should be separate items. ...{'sSortDataType': 'dom-text', 'aTargets', [2] }, {'sType', 'html', 'aTargets': [2] }
1

It sounds like the table is being sorted on the literal HTML strings, rather than the text. I haven't used that plugin but there is probably a way to override the default sorting method.

If not, give TableSorter a try, because it does this.

Comments

0

I would check the source of the plugin, and see if it's sorting on something like this

var sortText = $(this).html();

and change the html() method to text(). This will strip out all tags and sort it on the text node only.

Comments

0

The way I resolved the column sort with links is to use server side processing. This sets the sort process on the server side code, where the sort is handled by SQL. The link is added to each row after the fact. The resultant returned to the client side displayed correctly. Otherwise, the answer by tvanfosson seems to work well.

1 Comment

This does not solve the question the user is asking about fixing the jQeury datatable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.