Get cell edited previous value

Get cell edited previous value

arasaarasa Posts: 11Questions: 3Answers: 0

How can I get the original value from the cell, previous submit.
I have been dealing with https://datatables.net/forums/discussion/15981/how-to-get-a-value-from-a-row-on-edit but
console.log( sData[0]);
gives me all the objets. I need the value from this selected cell.
Can anyone help me, or referme to a posible solution?
Ty

**if this question has already been done elsewhere, I apologize, but can't find the answer

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,893Questions: 1Answers: 10,145 Site admin

    Are you able to give me a link to the page so I can see what software you are using? Also could to clarify when you want to get that data - before the edit, after? What is the goal?

    Thanks,
    Allan

  • arasaarasa Posts: 11Questions: 3Answers: 0
    edited October 2015

    Thanks Allan, here is a link

    I'll send the link to you

    i need to pass old and new value from edited cell to salida02.php

    editor.on( 'preSubmit', function ( e, data, action ) {
        if ( action === 'edit') {
            var transferencia = '<?php echo $transferencia;?>';
            var productoGet = '<?php echo $productoGet;?>';
            var pos_lado = '<?php echo $pos_lado;?>';
            $.ajax({
              type: "GET",
              url: "../funtions/salida02.php",
              data: {
                  pallet:  data.data.pallets.idPallet,
                  transferencia: transferencia,
                  productoGet:   productoGet,
                  pos_lado: pos_lado,
                  reserva: data.data.transferencia_des.fardos
              },
              success: function(e) {}
            });
        }
      } );
    

    thanks a lot

  • allanallan Posts: 61,893Questions: 1Answers: 10,145 Site admin

    Thanks for the clarification.

    There are two options:

    1) You could use modifier() to get the element that is being edited and then the data from it - for example:

    var modifier = editor.modifier();
    var currentData = table.row( modifier ).data();
    

    However, I would recommend a more robust approach:

    2) Get the current value from the database in your salida02.php script. Before the data is written to the database you could do a SELECT to get the existing values.

    Allan

  • arasaarasa Posts: 11Questions: 3Answers: 0
    edited October 2015

    Thanks you Allan

    just a consideration:

    My 1st bet was the option 2, and it's working 90% of times, but, in some random occasions, looks like my datatables update the db before salida02.php can read the original value and salida02.php read the updated value NOT the original.

    I going to test the 1st option... thanks again

  • arasaarasa Posts: 11Questions: 3Answers: 0

    for the 2nd option,

    how can I stop submit until ajax success?? just to be sure that my SELECT took the date before it's be written to the datatables?

  • allanallan Posts: 61,893Questions: 1Answers: 10,145 Site admin
    Answer ✓

    For option 2 I would suggest not having a separate script to get the values! Just have whatever script you are currently using for the edit also get the current values from the database before it does the edit.

    If you are using the PHP libraries for Editor, the preEdit event will be executed at that point - see the event documentation.

    Allan

This discussion has been closed.