trouble editing a row

trouble editing a row

El_principiante_17El_principiante_17 Posts: 2Questions: 1Answers: 0

I am doing a simple CRUD on datatable because I am new to programming. Everything works perfectly for me except modifying. Can someone enlighten me and tell me why it doesn't work? I'm doing everything according to the bibliography. But at the time of modifying the row is not painting me with the changes and I no longer know what it can be. The worst thing is that it does not give me any type of error or anything

Javascript code fragment where I estimate the problem is~~~~:

   if (editar == false) {

//it works perfectly
console.log("Estor entrando a pintanr un fila nueva");

                tabla_personas.rows.add([{
                    "Id": Id,
                    "nombre": nombre,
                    "pais": pais,
                    "edad": edad

                }])
                    .draw();
            }
            else {

//but this has me on the verge of insanity

                tabla_personas.rows(rowIndex).data([{
                    "Id": Id,
                    "nombre": nombre,
                    "pais": pais,
                    "edad": edad

                }])
                    .draw();

            }


            editar = false;

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765
    Answer ✓

    I think you need to remove the [] from the .data() API. Also you are using tabla_personas.rows(rowIndex).data([...}); to set the data but rows().data() only gets data. You need to use row().data() to set the data, something like this:

    tabla_personas.row(rowIndex).data( {
            "Id": Id,
            "nombre": nombre,
            "pais": pais,
            "edad": edad
     
        } )
            .draw();
    
    

    Kevin

  • El_principiante_17El_principiante_17 Posts: 2Questions: 1Answers: 0

    Thanks kevin brother !! I no longer had nails, hair or coffee ... lol

Sign In or Register to comment.