I have two different types of informations and I don't know how to merge then.
$('#usersTable').DataTable( {
initComplete: function () {
this.api().columns([5, 6]).every( function () {
var column = this;
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.header()) )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
$( select ).click( function(e) {
e.stopPropagation();
});
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' )
} );
} );
}
} );
// TABLE TRANSLATION
$('#usersTable').DataTable({
"language": {
"decimal": ",",
"thousands": ".",
"sEmptyTable": "Nenhum registro encontrado",
"sLoadingRecords": "Carregando...",
"sProcessing": "Processando...",
"sZeroRecords": "Nenhum registro encontrado",
"sSearch": "Pesquisar",
"oPaginate": {
"sNext": "Próximo",
"sPrevious": "Anterior",
"sFirst": "Primeiro",
"sLast": "Último"
},
"oAria": {
"sSortAscending": ": Ordenar colunas de forma ascendente",
"sSortDescending": ": Ordenar colunas de forma descendente"
}
}
})
I know I cannot let two blocks because will occurs a reinitialise error. I tried to copy the second block (starting on "language"
) and paste on the first block, but it doesn't work. I also tried to use a class on the second block but dataTable cannot load it.
What is the correct way to do this?