Help call Rest and populate another table via Click

0

Well I need a help, I have a Datatable that is already working, when I click on a record, I call a rest and I get the data and I try the other Datatable, there's the problem I've tried in several ways, but it never displays the data, could anyone give me a hand? my code below as it stands today.

    $('#btnConsultar').click(function() {

        var apuracao = $('#indsApuracaos').val();
        var periodo = $('#txtPeriodo').val();
        var cpf = $('#txtCPF').val();
        var raizCNPJ = $('#empresaAgrupadora').val();

        tableEvtBasesTrab = $('#tableEvtBasesTrab').DataTable({
            "processing": true,
            "serverSide": true,
            "pageLength": 5,
            "searching":false,
            "destroy": true,
            "lengthMenu": [ [5], [5] ],
            "language": {
                "decimal":        "",
                "emptyTable":     "Sem dados disponíveis na tabela",
                "lengthMenu": "_MENU_ registros por página",
                "zeroRecords": "Nada Encontrado",
                "info": "Página _PAGE_ / _PAGES_",
                "infoEmpty": "Nenhum registro disponível",
                "infoFiltered": "(filtrado de _MAX_ registros totais)",
                "search": "Filtrar registros :",
                "loadingRecords": "Carregando...",
                "processing":     "Processamento...",
                "paginate": {
                    "first":      "Primeiro",
                    "last":       "Último",
                    "next":       "Próximo",
                    "previous":   "Anterior"
                },
                    "aria": {
                        "sortAscending":  ": Ativar para classificar coluna ascendente",
                        "sortDescending": ": Ativar para classificar coluna descendente"
                    }
                },
                "ajax": {
                    "url": "../rest/totalizadorS5001/busca",
                    parametros : [ 
                        {
                            name : 'apuracao',
                            value :  apuracao
                        },
                        {
                            name : 'periodo',
                            value :  $.utils.parseAnoMes($('#periodo').val())
                        },
                        {
                            name : 'cpf',
                            value :  cpf
                        },  
                        {
                            name : 'raizCNPJ',
                            value :  raizCNPJ
                        }
                    ],
                    "data": function ( data ) {
                    //
                    }
                },
                "columns": [
                { 
                    "width": "20%",
                    "data": null,
                    "render" : function (data, type, row) {
                        return data.atrIdEsoEve5001;
                    }
                },
                { 
                    "width": "20%",
                    "data": null,
                    "render" : function (data, type, row) {
                        return data.atrNrRecArqBase;
                    } 
                },  
                { 
                    "width": "20%",
                    "data": null,
                    "render" : function (data, type, row) {
                        return data.atrIndApuracao;
                    }
                },
                { 
                    "width": "20%",
                    "data": null,
                    "render" : function (data, type, row) {
                        return data.atrPerApur;
                    }
                },
                { 
                    "width": "20%",
                    "data": null,
                    "render" : function (data, type, row) {
                        return data.atrTpInsc;
                    }
                },
                { 
                    "width": "20%",
                    "data": null,
                    "render" : function (data, type, row) {
                        return data.atrNrInsc;
                    }
                },
                { 
                    "width": "20%",
                    "data": null,
                    "render" : function (data, type, row) {
                        return data.atrCpfTrab;
                    }
                },
                { 
                    "width": "20%",
                    "data": null,
                    "render" : function (data, type, row) {
                        return data.atrId;
                    }
                }
                ],
                drawCallback : function( settings ) {
                //
                },
                "order": [[ 0, 'asc' ]],
                "displayLength": 5
        });
    });

    $('#tableEvtBasesTrab tbody').on('click', 'tr', function () {

        var esoEvento5001 = tableEvtBasesTrab.row(this).data();
        var atrIdEsoEve5001 = esoEvento5001.atrIdEsoEve5001;

        var dataSetProcJudTrab = new Array();

        $.rest.get({
            servico : 'totalizadorS5001/buscaPorId',
            parametros : [ 
                {
                    name : 'atrIdEsoEve5001',
                    value : atrIdEsoEve5001
                }
            ],
            sucesso : function(data) {
                console.log(data);
                dataSetProcJudTrab = data.procJuds;
                console.log(dataSetProcJudTrab);
            }
        });

        var tableProcJudTrab = $('#tableProcJudTrab').DataTable({
            "processing": true,
            "serverSide": true,
            "pageLength": 5,
            "searching":false,
            "destroy": true,
            "data": dataSetProcJudTrab,
            "lengthMenu": [ [5], [5] ],
            "language": {
                "decimal":        "",
                "emptyTable":     "Sem dados disponíveis na tabela",
                "lengthMenu": "_MENU_ registros por página",
                "zeroRecords": "Nada Encontrado",
                "info": "Página _PAGE_ / _PAGES_",
                "infoEmpty": "Nenhum registro disponível",
                "infoFiltered": "(filtrado de _MAX_ registros totais)",
                "search": "Filtrar registros :",
                "loadingRecords": "Carregando...",
                "processing":     "Processamento...",
                "paginate": {
                    "first":      "Primeiro",
                    "last":       "Último",
                    "next":       "Próximo",
                    "previous":   "Anterior"
                },
                    "aria": {
                        "sortAscending":  ": Ativar para classificar coluna ascendente",
                        "sortDescending": ": Ativar para classificar coluna descendente"
                    }
                },
                "ajax": {
                    "data": function ( data ) {
                    //
                    }
                },
                "columns": [
                { 
                    "width": "20%",
                    "render" : function (data, type, row) {
                        console.log("Chegou Aqui");
                        console.log(data);
                        return data.atrNrProcJud;
                    }
                },
                { 
                    "width": "20%",
                    "render" : function (data, type, row) {
                        return data.atrCodSusp;
                    } 
                }
                ],
                drawCallback : function(settings) {
                //
                },
                "order": [[ 0, 'asc' ]],
                "displayLength": 5
        });
    });
});     
    
asked by anonymous 06.04.2018 / 01:52

1 answer

0

The friend idea as it is today is only popular when I click on the record line I'm going to have to popular some 5 different Datables yet, so I want to know how it does in one so, for me to solve the rest, it is making a REST call in the above code, which returns a JSON already, wanted to know the way it's like getting the JSON and show in the Datatable. The table I want to populate that is in the source code is tableProcJudTrab.

    
06.04.2018 / 04:19