Show/Hide column title/sorting

Show/Hide column title/sorting

tnelsontnelson Posts: 4Questions: 0Answers: 0
edited April 2013 in General
I am trying to show or hide the title and sort arrows on a column based on my ajax response. This seems like something I should be able to do in fnServerData. I can't seem to find an example anywhere, has anyone managed to do this? This is as close as I've come:

[code]
fnServerData: function( sSource, aoData, fnCallback, oSettings) {
$.getJSON(sSource, aoData, function (json) {
if (json['error']) {
console.log(json); // placeholder
}
else {
var show_stars = json['show_stars'];
var stars_col_defs = oSettings.aoColumns[0];

stars_col_defs.bSortable = show_stars;

if (show_stars) {
// copy value from next column which is sortable
stars_col_defs.sSortingClassJUI = oSettings.aoColumns[1].sSortingClassJUI;
stars_col_defs.sTitle = 'Score';
}
else {
stars_col_defs.sSortingClassJUI = '';
stars_col_defs.sTitle = '';
}

// console.log(oSettings.aoColumns[0]);
// console.log(oSettings.aoColumns[1]);

fnCallback(json);
}
});
[/code]

Thanks for any advice
Tony
This discussion has been closed.