jquery datatable pick up values from an input

0

Personal Talk!

I need your help! I am using the jquery datatable plugin to generate a dynamically paged table in a modal, so alright, but inside this table I have an input that I need to get the value typed after the user confirm on a button in the click event, then this is the problem I got get the value with the following code:

$('#TabelaPecas2 > tbody  > tr').find("input[id^='txtQuantidade']").each(function(){
if($(this).val() != "")
{
       alert($(this).val());
}
});

but returns only the inputs from the first page. in the code below I am getting the data of all the pages but I can not get the value typed by the user.

var table = $('#TabelaPecas2').DataTable();
table.rows().every( function () {
    var data = table.row( this ).data();
    //pega valores input da terceira coluna
    console.log($(data[2]).val());
});

UPDATE

Personal, whom I was interested to do as follows:

            var table = $('#TabelaPecas2').DataTable();
            table.rows().every( function ( rowIdx, tableLoop, rowLoop ) { 
                var dados = table.row( this ).data();
                var cell = table.cell({ row: rowIdx, column: 2 }).node();
                if ($('input', cell).val() != ""){
                    var objPecas = new Peca(dados[0], dados[1], $('input', cell).val());
                    objServico.pecas.push(objPecas);
                }
    
asked by anonymous 11.07.2016 / 14:49

1 answer

0

Boss I have something like that. In case my table contains quantities and items received. In the case the Rows I created put and in the loop I get td.quantity And in the input I do the same and I put in the find td.class input I think that's what you need.

 $("#table").find('tbody tr').each(function () {
                var quantityCashier = $(this).find('td.quantity');
                var quantityInput = $(this).find('td.received input');

            });
    
11.07.2016 / 16:00