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

后端 未结 4 983
借酒劲吻你
借酒劲吻你 2021-01-16 08:37

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\

相关标签:
4条回答
  • 2021-01-16 09:18

    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.

    0 讨论(0)
  • 2021-01-16 09:21

    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 讨论(0)
  • 2021-01-16 09:23

    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.

    0 讨论(0)
  • 2021-01-16 09:23

    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.

    0 讨论(0)
提交回复
热议问题