0

I am using Jquery DataTables to populate some data on my page, I have come to a point where everything works fine except i am unable to hide sorting arrow for one of the column.

I need to use aoColumnDefs parameter to accompolish any column level task.

When i hardcode "aoColumnDefs": [{ "bSortable": false, "aTargets": [2]}], sorting arrow gets hidden/disabled from column[2], As i am using HTML5 and passing every parameter from HTML to make my whole DataTable generic, I need to pass this aoColumnDefs through variables.

I have tried this

var mSortingString = [];
var disableSortingColumn = "2"; mSortingString.push({ "bSortable": false, "aTargets": [disableSortingColumn] });

and then assigning this mSortingString string as value to aoColumnDefs but that doesnt seems to work. I can see mSortingString having above data but that doesn't disable sorting arrows. Another thing is as I have given variable disableSortingColumn value of 2, but in mSortingString array, its 1.

Can anyone help me in right direction, I think its my minimal knowledge of Javascript.

Have tried looking at this Create JavaScript array (JSON format) for DataTables aoColumnDefs but this doesnt work for me.

Community
  • 1
  • 1
Jay
  • 1,037
  • 5
  • 23
  • 41

1 Answers1

3

"2" is a string, and DataTables wants an int. So make it

var disableSortingColumn = 2;

And it should work. I created a jsFiddle for it, fwiw. http://jsfiddle.net/CYcc2/

Bumptious Q Bangwhistle
  • 4,689
  • 2
  • 34
  • 43