I have the following datatable:
$(document).ready(function () {
tabla_productos = $("#idtabla_productos").DataTable({
"scrollX": true, "scrollY": "300px", "scrollCollapse": true, "searching": false, "paging": false, "ordering": false, "info": false, "autowidth": false
});
<table id="idtabla_productos" class="table table-striped table-bordered nowrap" cellspacing="0" width="100%" style="margin-bottom: 0 !important;">
<thead style="background-color: rgba(34, 255, 0, 0.34);">
<tr>
<th style="text-align: right">Cantidad
</th>
</tr>
</thead>
<tbody>
<% int i = 1;
foreach (var item in Model)
{ %>
<tr >
<td>
<input type="number" id="idcantidad_<%:i.ToString() %>" class="fila_marcada" data-fila="<%:i%>" />
</td>
</tr>
<% } %>
</tbody>
</table>
In the next event, I need to get the value of the row, which is defined in the input that is inside the td (data-row = <%: i% >):
$('#idtabla_productos tbody').on('keypress', 'tr', function (event) {
//var fila=$(this).data('fila');si el data-fila estuviera en tr, obtendria el que está en el tr, pero en este caso necesito la fila(data-fila) del input que esta dentro del td
I've tried to do something like this:
$(this).parents('td').data('fila');
});
});
but it does not work for me, I would like to be able to get a solution, I would appreciate it very much please