Editor - Get edit information after cell Edit

Editor - Get edit information after cell Edit

VascoOliveiraVascoOliveira Posts: 22Questions: 7Answers: 0

In order to add Editing capabilities our Datatables, we started to use the free CellEdit plugin. Unfortunatelly, as the project grows, it no longer offers the type of Editing capabilities that our users need.

As such, i've downloaded the 15 day trial Editor, and i will evaluate it during the next days.

The CellEdit component offered a function callback, that when any cell changed, it allowed to obtain:
- The updated Cell value,
- The Cell old Value,
- The full updated Row

 var table = $('#myTable').DataTable();

    function myCallbackFunction (updatedCell, updatedRow, oldValue) {
        console.log("The new value for the cell is: " + updatedCell.data());
        console.log("The values for each cell in that row are: " + updatedRow.data());
    }

    table.MakeCellsEditable({
        "onUpdate": myCallbackFunction
    });

I'm researching the Editor plugin, but wasn't able to understand how can i obtain the same information using the Editor plugin.
How can obtain the same information with the Editor plugin?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Answer ✓

    I hadn't seen that plug-in for DataTables before - thanks for introducing me to it.

    Editor doesn't offer something that is directly compatible with that callback, but it does provide a range of events which would be suitable. postEdit is the one that might be of most interest to you. What it doesn't immediately provide is the cell that was updated.

    For that you could use:

    editor.on( 'postEdit', function ( e, json, updatedRow ) {
      let updatedCell = table.cell( editor.modifier() );
      ...
    } );
    

    If the original value is required, preEdit could be used.

    Regards,
    Allan

This discussion has been closed.