FixedColumns + Sorting

FixedColumns + Sorting

jrevaijrevai Posts: 6Questions: 0Answers: 0
edited May 2012 in General
If you create a datatable using the FixedColumns plugin and set bJQueryUI to true, sorting one of the columns fixed by the FixedColumns plugin throws a javascript error.

You can reproduce the bug on the demo site of the FixedPlugins: http://datatables.net/release-datatables/extras/FixedColumns/themed.html.
Try sorting on the Rendering engine column, and you can see the following javascript error:

TypeError: 'undefined' is not an object (evaluating '$('span.DataTables_sort_icon', aoCloneLayout[i][j].cell)[0].className')

The error comes from the FixedColumn.js _fnClone method. It affects only the rendering of the jquery UI sort icon, sorting the rows works fine, the sorting icon wont change will always show it's default state.

I didn't had the time to go too deep into the problem, but what I saw: there is a aoCloneLayout array, and the code is trying to copy the sort classes from it's sorticon, to the dom's sorticon. But the aoCloneLayout object was created based on the this.s.dt.aoHeader object, which was the hidden thead element of the fixed body table, which had no sorticons in it, so $('span.DataTables_sort_icon', aoCloneLayout[i][j].cell) has a length of 0.

However, I fixed this by replacing this:

this.className = $('span.DataTables_sort_icon', aoCloneLayout[i][j].cell)[0].className;

with this:

for ( i=0, iLen=aoCloneLayout.length ; i

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    edited May 2012
    Hi Judit,

    Could you try the latest nightly of FixedColumns please? You can get it front he download page: http://datatables.net/download/ . This error should already be addressed in that version.

    Allan
  • jrevaijrevai Posts: 6Questions: 0Answers: 0
    Hi Allan,

    Thank You, this solved the issue.

    Judit
This discussion has been closed.