Show data from an input in another column
Show data from an input in another column
albert04
Posts: 2Questions: 2Answers: 0
I want to make that when increasing the <input> type number, this data is shown in column 9 where a
$('#dataTableRequestRM').DataTable({
"searching": false,
"fnRowCallback": function( nRow, data, iDisplayIndex, iDisplayIndexFull ) {
if ( data["default"] == true )
{
$('td', nRow).css('background-color', '#ffdf00')
$('td', nRow).css('color', '#000000')
}
},
processing: true,
lengthMenu: [100, 50, 75],
order: [
[0, "asc"]
],
deferRender: true,
data: data,
columns: [{
data: null,
render: function(data, type, row) {
return data["provedorMateriaPrimaSDMPtr"]["materiaPrimaPtr"]["nombre"]
}
},
{
data: null,
render: function(data, type, row) {
return data["provedorMateriaPrimaSDMPtr"]["proveedorPtr"]["nombre"]
}
},
{
data: null,
render: function(data, type, row) {
return formatter.format(data["provedorMateriaPrimaSDMPtr"]["costo"])
}
},
{
data: null,
render: function(data, type, row) {
return data["provedorMateriaPrimaSDMPtr"]["cantidadMinima"]
}
},
{
data: null,
render: function(data, type, row) {
return formatter.format( parseInt(data["provedorMateriaPrimaSDMPtr"]["cantidadMinima"]) * parseInt(data["provedorMateriaPrimaSDMPtr"]["costo"]) )
}
},
{
data: null,
render: function(data, type, row) {
return data["transporteSDMPtr"]["tipoEnvio"]
}
},
{
data: null,
render: function(data, type, row) {
return data["transporteSDMPtr"]["diasEntrega"]+" Day(s)"
}
},
{
data: null,
render: function(data, type, row) {
return formatter.format(data["transporteSDMPtr"]["precio"])
}
},
{
data: null,
render: function(data, type, row) {
return data["transporteSDMPtr"]["porcentajePrecio"]+"%"
}
},
{
data: null,
render: function(data, type, row) {
return "<span>2</span>"
}
},
{
data: null,
render: function(data, type, row) {
return '<span>1</span>'
}
},
{
data: null,
render: function(data, type, row) {
return '<input type="number" class="catidadComprar form-control" aria-describedby="inputGroupPrepend" id="input_purchasing_cart'+data["objectId"]+'" min="'+data["provedorMateriaPrimaSDMPtr"]["cantidadMinima"]+'" value="'+data["provedorMateriaPrimaSDMPtr"]["cantidadMinima"]+'" required>'
}
},
{
data: null,
render: function(data, type, row) {
let json = JSON.stringify(data).replace(/\"/g,""")
return '<button type="button" class="btn btn-primary font-weight-bold" data-toggle="tooltip" onclick="addToCart('+json+')" data-placement="bottom" title="Add to cart"> <i class="fas fa-cart-plus"></i></button>'
}
}
]
})
}
$( "#dataTableRequestRM" ).on( "change", "input", function () {
table = $('#dataTableRequestRM').DataTable();
var td = $(this).closest('tr').find('td:eq(9)');
table.cell( td ).data($(this).closest('tr').data()).draw();
});
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin