Commit b7f72228 by Billy Larru

agregando propiedades adicionales al makeDatatable

parent 1c7ec5c0
......@@ -285,61 +285,88 @@ function primeraLetraMayuscula(str) {
const makeDatatable = (jsonForDatatable = { data: [], columns: [], columnDefs: [], wrapsNameDatatable: ``, classNameForDatatable: ``, footer: false}) => {
let data = jsonForDatatable.data;
let columns = jsonForDatatable.columns;
let columnDefs = jsonForDatatable.columns;
let data = jsonForDatatable.data;
let columns = jsonForDatatable.columns;
let columnDefs = jsonForDatatable.columns;
let wrapsNameDatatable = jsonForDatatable.wrapsNameDatatable;
let nameDatatable = `${wrapsNameDatatable}-datatable`;
let classNameForDatatable = jsonForDatatable.classNameForDatatable;
let wrapsNameDatatable = jsonForDatatable.wrapsNameDatatable;
let nameDatatable = `${wrapsNameDatatable}-datatable`;
let classNameForDatatable = jsonForDatatable.classNameForDatatable;
let table_head = `
let table_head = `
<table id="${nameDatatable}" class="${classNameForDatatable}" cellspacing="0" width="100%">`;
let table_head_th = `
let table_head_th = `
<thead>
<tr>`;
columns.forEach((obj) => {
let title = `undefined`;
if (obj.title) {
title = obj.title;
} else if (obj.data) {
title = obj.data;
}
table_head_th += `
columns.forEach((obj) => {
let title = `undefined`;
if (obj.title) {
title = obj.title;
} else if (obj.data) {
title = obj.data;
}
table_head_th += `
<th>${title}</th>`
})
table_head_th += `
})
table_head_th += `
</tr>
</thead>`
let table_foot_th = ``;
if (jsonForDatatable.footer) {
table_foot_th = `
let table_foot_th = ``;
if (jsonForDatatable.footer) {
table_foot_th = `
<tfoot>
<tr>`;
columns.forEach((obj) => {
let title = `undefined`;
if (obj.title) {
title = obj.title;
} else if (obj.data) {
title = obj.data;
}
table_foot_th += `
columns.forEach((obj) => {
let title = `undefined`;
if (obj.title) {
title = obj.title;
} else if (obj.data) {
title = obj.data;
}
table_foot_th += `
<th>${title}</th>`
})
table_foot_th += `
})
table_foot_th += `
</tr>
</tfoot>
`
}
}
let table_foot = `</table>`
let table_foot = `</table>`
$(`#${wrapsNameDatatable}`).empty().append(`${table_head}${table_head_th}${table_foot_th}${table_foot}`);
$(`#${nameDatatable}`).DataTable({
data,
columns,
columnDefs
});
$(`#${wrapsNameDatatable}`).empty().append(`${table_head}${table_head_th}${table_foot_th}${table_foot}`);
$(`#${nameDatatable}`).DataTable({
data,
columns,
columnDefs,
bSort: false,
bFilter: false,
aaSorting: [],
ordering: false,
bLengthChange: false,
bInfo: true,
paging: true,
iDisplayLength: 20,
bStateSave: false,
autoWidth: false,
responsive: true,
stateSave: true,
language: {
lengthMenu: "Mostrar: _MENU_",
zeroRecords: "&nbsp;&nbsp;&nbsp; No se encontraron resultados",
info: "&nbsp;&nbsp;&nbsp; Mostrando del _START_ al _END_ de un total de _TOTAL_ registros",
infoEmpty: "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros",
search: "Filtrar:",
loadingRecords: "Cargando...",
processing: '<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>',
paginate: {
first: "First",
last: "Last",
next: "Siguiente",
previous: "Anterior"
}
}
});
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment