Como atualizar informações do datatable ao clicar em um checkbox

Como atualizar informações do datatable ao clicar em um checkbox

akatsukiakatsuki Posts: 10Questions: 3Answers: 0

tenho uma datatable e quando o usuário clicar no checkbox quero atualizar as informações de uma coluna somente, com base nas minhas 2 listas var listaCxUn = {};var listaPlCxUn = {}; eu consigo pegar o evento do click no checkbox, porém não sei como manipular as informações das listas e atualizar essas mesmas informações na coluna "Qtd" no meu datatable, procurei algo parecido no fórum mas não encontrei, se alguém puder me ajudar, agradadeço"

var listaCxUn = {};
var listaPlCxUn = {};

$(document).ready(function () {

    $('#check_Qtd').click(function () {
        formatarProdutoEmbalagem();
    });

});

function formatarProdutoEmbalagem() {

    if ($('#check_Qtd').is(":checked")) {
      }
  }


function montarTelaProdutosConferenciaContagemProdutos(dados) {

    listaPlCxUn = dados.listPtLtCxUn;
    listaCxUn = dados.listCxUN;

    $('#div_detalhes_conferente_status').html(" ID: " + dados.idContagemEstoquePosicaoConferentes +    " Status:  " + dados.statusConferencia);
    $('#div_detalhes_conferencia_nome').html(" Nome: " + dados.conferente);
    $('#div_detalhes_conferencia_datas').html(" Início: " + dados.inicioConferencia +      "  Fim: " + dados.fimConferencia);
    $('#div_detalhes_conferente_qtd').html(" Total Itens: " + dados.qtdItens);

    var tag = '';

    if (listaCxUn === null || listaCxUn.length == 0) {

        tag += "<center><h3> Não existem dados para exibição</h3></center>";
        $("#div_tabela_detalhes_itens_conferente").html(tag);
        $("#modalDetalhesConferenteItens").modal('show');
        return;
    }

    tag += '<table id="tabelaConferenteItens"  overflow-y: auto; border="1" class="table table-striped table-bordered nowrap"  data-paging="false" data-info="false">';
    tag += '<thead>';
    tag += '<tr>';
    tag += '<th scope="col">Código</th>';
    tag += '<th scope="col">Nome</th>';
    tag += '<th scope="col" style="width:300px;" >Qtd</th>';
    tag += '</tr>';
    tag += '</thead>';
    tag += '<tbody>';

    for (i = 0; i < listaPlCxUn.length; i++) {
        var item = listaPlCxUn[i];
        tag += '<tr>';
        tag += '<td>' + item.codigo + '</td>';
        tag += '<td>' + item.descricao + '</td>';
        tag += '<td>' + item.qtd + '</td>';
        tag += '</tr>';
    }
    tag += '</tbody>';
    tag += '</table>';

    if ($.fn.dataTable.isDataTable('#tabelaConferenteItens')) {
        $('#tabelaConferenteItens').DataTable().destroy();
    }

    tabelaConferenteItens = $('#tabelaConferenteItens').DataTable({
        "ordering": false,
        "searching": false
    });

    $("#div_tabela_detalhes_itens_conferente").html(tag);
    $("#modalDetalhesConferenteItens").modal('show');
}


Answers

  • colincolin Posts: 15,234Questions: 1Answers: 2,597

    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

  • akatsukiakatsuki Posts: 10Questions: 3Answers: 0

    conseguir implementar o código, desde já agradeço pela ajuda.

Sign In or Register to comment.