problems with changing row with draw ()

problems with changing row with draw ()

massercmasserc Posts: 2Questions: 0Answers: 0
edited January 2019 in Free community support

I have a problem on changing row from data that come back from MySQL update I tried with the draw () function but I get this error:

datatables.min.js:129 Uncaught TypeError: Cannot set property '_aData' of undefined
    at s.<anonymous> (datatables.min.js:129)
    at s.data (datatables.min.js:115)
    at Object.<anonymous> (functions.js:76)
    at Function.each (jquery.min.js:2)
    at Object.success (functions.js:58)
    at i (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at y (jquery.min.js:4)
    at XMLHttpRequest.c (jquery.min.js:4)

my script and this:

$.ajax({
      type: "POST",
      url: url,
      data: form.serialize(), 
        success: function(data)
         {
           var json_txt = $.parseJSON(data);
           $.each(json_txt, function(i, item) {

              id_day = item.id_day;
              portata = item.nome_port;
              piatto = item.nome_pia;
              descrizione = item.dsc_piatti;
              ingredienti = item.ingred;
              eng_piatti = item.ing_piatti;                

                var table = $('#example').DataTable();
                    var tableRow = table.row( $('#update_table_' + id_day ) );
                    var rData = [
                        portata,
                        piatto,
                        descrizione,
                        ingredienti,
                        eng_piatti,
                    ]; 
                    table.row( tableRow ).data( rData ).draw();
                          
             });
            }
         });    

I do not understand the mistake you can help me?

P.S. sorry for my english

Replies

  • kthorngrenkthorngren Posts: 21,305Questions: 26Answers: 4,947

    My guess is that instead of table.row( tableRow ).data( rData ).draw(); on line 17 you want tableRow.data( rData ).draw();. tableRow received a Datatables row API instance with this var tableRow = table.row( $('#update_table_' + id_day ) );.

    Kevin

  • massercmasserc Posts: 2Questions: 0Answers: 0

    keep giving me this error ...... I changed row 17

    datatables.min.js:129 Uncaught TypeError: Cannot set property '_aData' of undefined
    at s.<anonymous> (datatables.min.js:129)
    at s.data (datatables.min.js:115)
    at Object.<anonymous> (functions.js:76)
    at Function.each (jquery.min.js:2)
    at Object.success (functions.js:58)
    at i (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at y (jquery.min.js:4)
    at XMLHttpRequest.c (jquery.min.js:4)

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @masserc ,

    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

This discussion has been closed.