56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
document.addEventListener('DOMContentLoaded', function () {
|
||
|
||
const table = $('#tablaDetalleVenta').DataTable({
|
||
paging: true,
|
||
searching: true,
|
||
ordering: true,
|
||
pageLength: 7,
|
||
lengthChange: false,
|
||
info: true,
|
||
autoWidth: false,
|
||
|
||
columnDefs: [
|
||
{ orderable: false}
|
||
],
|
||
|
||
dom:
|
||
"<'row mb-3'<'col-md-8'f><'col-md-4 text-end'l>>" +
|
||
"<'row'<'col-12'tr>>" +
|
||
"<'row mt-3'<'col-md-5'i><'col-md-7'p>>",
|
||
|
||
language: {
|
||
search: "",
|
||
searchPlaceholder: "Buscar insumo...",
|
||
zeroRecords: "No se encontraron insumos",
|
||
info: "Mostrando _START_ a _END_ de _TOTAL_ insumos",
|
||
infoEmpty: "No hay insumos para mostrar",
|
||
infoFiltered: "(filtrado de _MAX_ insumos totales)",
|
||
paginate: {
|
||
next: "›",
|
||
previous: "‹"
|
||
}
|
||
}
|
||
});
|
||
|
||
// Insertamos el select al lado del buscador
|
||
|
||
$('.dataTables_filter')
|
||
.addClass('d-flex align-items-center')
|
||
.append($('#columnFilter'));
|
||
|
||
const searchInput = $('.dataTables_filter input');
|
||
|
||
$('#columnFilter').on('change', function () {
|
||
const colIndex = $(this).val();
|
||
|
||
table.search('').columns().search('').draw();
|
||
|
||
searchInput.off('keyup').on('keyup', function () {
|
||
if (colIndex === "") {
|
||
table.search(this.value).draw();
|
||
} else {
|
||
table.column(colIndex).search(this.value).draw();
|
||
}
|
||
});
|
||
});
|
||
}); |