Datatable not show record from list javascript

Datatable not show record from list javascript

vantonio79vantonio79 Posts: 1Questions: 0Answers: 0
edited August 9 in Free community support

Hello, I'am new to datatables and I want to load data from list json javascript.
I load data in list via this script javascript

function costruisciListaOrdini(result){
    let vet = null;
        vet = JSON.parse(result);
   catch (e) {
      alert("sto qua 0 "" "+e.message);
   let lista=[];
   if(vet != null){
      let i=0;
      for (i=0;i<vet.length;i++){
        var obj={};
        obj.Cliente=vet[i].cliente.nomeCliente+" "+vet[i].cliente.cognomeCliente;       
  return lista;

and after in other function javascript i create datatable with this code:

function recuperaOrdiniAttivi(){
    let json_dati='{"operazione":"5"}';
           data: json_dati,
           type: 'POST',
           contentType: "application/json",
           processData: false,
           async: false, //blocks window close
           success: function(result) {                            
                listaOrdini = null;
                 var table = $('#tblElencoOrdiniAttivi').DataTable();
                        paging: true,
                        ordering: true,
                        info:     true,
                        responsive: true,
                        data: listaOrdini,  
                                columns: [
                                            { "data": "Codice" , render: function ( data, type, row ) { var html='<p>'+row.Codice+'</p>'; return html;}},
                                            { "data": "Cliente" , render: function ( data, type, row ) { var html='<p>'+row.Cliente+'</p>'; return html;}}
                                columnDefs: [
                                       { targets: 0, width: '10%' },
                                       { targets: 1, width: '10%' }

Buw whent tables is created no record display in tables, when list json has 2 record.
why table not see record?
Thank you very much

Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide


  • kthorngrenkthorngren Posts: 19,444Questions: 26Answers: 4,607
    edited August 9

    There is nothing obvious in the code snippets. Do you get any alerts or errors in the browser's console?

    Can you post the value of listaOrdini after this statement?



Sign In or Register to comment.