chris
chris

Reputation: 36937

jQuery Datatables aoColumns Sorting error

Ok I am using DataTables from Datatables.net I have one table that seems to be suffering a sort issue. Currently "aoColumns" is set up like

null,
{"iDataSort": 2, "bSortable": true},
{"bVisible": true, "sType": "num"},
{"iDataSort": 4, "bSortable": true},
{"bVisible": true, "sType": "num"}

What it is is 5 columns 2 of which are hidden so.. 0 is the column with the inital sort issue that sparked this post. 1 is supposed to be display purpose only 2 is hidden and is supposed to act as the sort for 1 3 is supposed to be display purpose only 4 is hidden and supposed to act as the sort for 3

I need the first column to recognize as html so it strips out the HTML as it has links in it, currently its set to null and the problem with this is it breaks the sorting in Chrome.

I have tried to make it like

{"sType": "html", "bSortable": true},
{"iDataSort": 2, "bSortable": true},
{"bVisible": true, "sType": "num"},
{"iDataSort": 4, "bSortable": true},
{"bVisible": true, "sType": "num"}

Which breaks the table itself.

First I tried

{ "sType": "html", "bSortable": true},
{ "sType": "num", "bSortable": true},
{ "sType": "num", "bSortable": true}

(before I realized I had 2 hidden columns) Which this worked but broke the table layout physically. So now Im stuck trying to go from a to b keeping all 5 columns the 3 displayed, and the 2 hidden and failing

Upvotes: 0

Views: 5554

Answers (1)

Dean
Dean

Reputation: 302

Try this:

aoColumns: [
   {"sType": "html", "bSortable": true},
   {"iDataSort": 2, "bSortable": true, "bUseRendered":false},
   {"bVisible": true, "sType": "numeric"},
   {"iDataSort": 4, "bSortable": true, "bUseRendered":false},
   {"bVisible": true, "sType": "numeric"}
]

I had to do this with a column that rendered images instead of the values and then created a hidden column which had the actual values to sort on.

I hope this helps

Upvotes: 2

Related Questions