How to update a row from external data?

How to update a row from external data?

Wilmer30Wilmer30 Posts: 33Questions: 10Answers: 1

Hi,
I try to update some fields in a row, the problem is that it does not work.

              borrar.data()[1] = datos.rol;
              borrar.data()[2] = datos.descripcion;
              console.log(borrar.data()); //Here I see the changes of the data
              borrar.invalidate().draw();

External data I bring from an ajax.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    That looks like it should work. What's the original data source for the table? What do you see if you do console.log(borrar.data()); after the draw?

    Allan

  • Wilmer30Wilmer30 Posts: 33Questions: 10Answers: 1
    edited August 2017

    Go back to te value:

                  console.log(borrar.data()); //(5) ["2", "aaaa", "aaa", "Activo".....
                  borrar.invalidate().draw();
                  console.log(borrar.data()); //(5) ["2", "Fábrica", "Usuario Fábrica del Sistema", "Activo".....
    
    

    thanks for your answer

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    It goes back to the original value?

    In that case use:

    borrar.invalidate('data').draw();
    

    That is reverts suggests that the table is originally sourced from HTML directly and it therefore tries to read from there again, unless told otherwise.

    Allan

  • Wilmer30Wilmer30 Posts: 33Questions: 10Answers: 1

    It will have something to do with using DataTables 1.10.12

  • Wilmer30Wilmer30 Posts: 33Questions: 10Answers: 1
    edited August 2017

    That was the problem thank you very much allan

This discussion has been closed.