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 accomplish 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 doesn't 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, it is 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 doesn't work for me.
"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/