-2
I want to put a CHECKBOX field in the first column where I will be able to select all the records, or just a record.
var montarDataTable = function(){
if (!$.fn.DataTable.isDataTable('#reciclagem-lista')) {
$("#reciclagem-lista").DataTable({
oLanguage: { sUrl: "dataTable.portugues.txt"},
dom: 'Bfrtip',
buttons: [
],
responsive: true,
data: window.ds,
pageLength: 10,
searching: false,
lengthChange: false,
columns: [
{ title: "CHECKBOX"},
{ title: "Código", data: "codigo"},
{ title: "Status", data: "status"},
{ title: "Data do Cadastro", data: "data_cadastro"},
],
order: [[ 0, 'asc' ]]
});
}else{
reloadDataTable('reciclagem-lista', window.ds);
}
};
/* Recarregando dados no DataTable já criado */
function reloadDataTable(table_id, dados){
table = $("#"+table_id).dataTable();
oSettings = table.fnSettings();
table.fnClearTable(this);
if(dados.length !== 0){
for (var i=0; i<dados.length; i++){
table.oApi._fnAddData(oSettings, dados[i]);
}
}
oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
table.fnDraw();
}
Has this feature in documentation.
– Sam