I need to disable sorting for all the columns with no data in it. I am looking to do it using DataTable or jQuery. If I have multiple tables, I should be able to iterate through all of them and return true or false for each column. So that I can take the result and disable column sorting. This is what I have so far, eventhough the code is incomplete.
function detectEmptyColumn(index) {
var sStatus = [], status ='';
var colors = ['red','green','blue','yellow','purple','black','cyan','green'];
$('.data-table').eq(index).find('tbody').each(function(i) {
var self = this;
$(self).find('tr td').each(function(j) {
if (j > 0) {
$(self).find('tr').each(function(k) {
var $tableCell = $(this).find('td:visible').eq(j);
$tableCell.css('border','2px solid '+colors[j]);
var $innerWrapper = $('.inner-wrapper', $tableCell);
status = ('a', $innerWrapper).size() > 0;
sStatus[k] = status;
if (status) return false;
});
}
});
});
return status;
}
function disableEmptyColumnSorting() {
$('.data-table').each(function(index) {
var status = detectEmptyColumn(index);
});
}
And this is how Datatable td looks like:
<td class="reading-level interpTRC_no_interp
firstCol
"><div class="inner-wrapper" style="position: relative;">
<span title="-5" class="sortindex"></span>
<a href="/test/test123">
<PC
<sup>F</sup>
</a>
</div></td>
bsortable: false
property in theaoColumns
section. DataTables Columns – War10ck