Input select dentro de columna
Input select dentro de columna
leo-villao
Posts: 2Questions: 1Answers: 0
in General
I am creating a Datatable with information from a database with ajax, so far so good., But inside a column I send and show an input type select, I would like help to be able to go through the table and obtain the value and text of the select. Thank you so much
const tableInfDifAjuste = $("#table-result-if-dif-ajuste").DataTable({
"destroy": true,
"responsive": true,
"aaSorting": [[1, "asc"]],
"ajax": {
"method": "POST",
"url": "./?action=tf_informeDifFinalAjuste",
"data": {"option": option, "evcodigo": evcodigo}
},
"columns": [
{"data": "evcodigo", "width": "6%"},
{"data": "name", "width": "20%"},
{"data": "unidad", "width": "6%"},
{"data": "stock", className: "text-right", "width": "6%"},
{"data": "conteofinal", className: "text-right", "width": "6%"},
{"data": "diferencia", className: "text-right", "width": "6%"},
{"data": "fechacierre", className: "text-center", "width": "15%"},
{"data": "ingreso", className: "text-center", "width": "6%"},
{"data": "egreso", className: "text-center", "width": "6%"},
{"data": "acciones", "width": "20%"}, // show input select <<<<--------------------
],
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.11/i18n/Spanish.json"
},
dom: 'Bfrtip',
buttons: [
{
extend: 'excelHtml5',
title: 'INFORME INVENTARIO : ',
message: "INFORME FINAL DIFERENCIAS",
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6] //exportar solo la primera y segunda columna
}
},
{
extend: "pdfHtml5",
filename: function () {
return "INFORME FINAL DIFERENCIAS"
},
title: function () {
var searchString = tableInfDifAjuste.search();
return searchString.length ? "Search: " + searchString : "Informe Inventario : INFORME FINAL DIFERENCIAS"
},
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6] //exportar solo la primera y segunda columna
}
},
{
extend: 'procesar',
text: 'Procesar Ajuste'
}
]
})
$("#table-result-if-dif-ajuste").show()
$.fn.dataTable.ext.buttons.procesar = {
className: 'buttons-alert',
action: function ( e, dt, node, config ) {
let d = tableInfDifAjuste.rows().data();
d.each(function (value, index) {
console.log(value.acciones) // view val of column![](https://datatables.net/forums/uploads/editor/ao/3t3ifazve4s1.png "")
});
}
};
Replies
You could
column().nodes()
, and then query each node to get the selected value,Colin