In case the table has class 'trans'
- run dataTable()
and columnFilter()
; otherwise just run dataTable()
.
Is it possible to not repeat the dataTable()
part?
$('#dt_a').each(function() {
if ($(this).hasClass('trans')) {
$(this).dataTable({
"sDom": "<'row'<'span6'<'dt_actions'>l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap_alt",
"oLanguage": {
"sLengthMenu": "_MENU_ records per page"
}
})
.columnFilter({
sPlaceHolder: "head:before",
aoColumns: [
null,
{ type: "text" },
{ type: "text" },
{ type: "date-range" },
{ type: "text" },
{ type: "text" },
null,
null
]
});
} else {
$(this).dataTable({
"sDom": "<'row'<'span6'<'dt_actions'>l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap_alt",
"oLanguage": {
"sLengthMenu": "_MENU_ records per page"
}
});
}
});
NOTE:
columnFilter
is an extension to dataTable
.