开发者

jquery datatable plugin doesn't seem to sort columns with links properly

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开发者_JAVA百科://www.datatables.net/usage/features

Any suggestions?


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.


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜