Using editor to edit value before refreshing datatables

Using editor to edit value before refreshing datatables

islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1

Hello.

I'm using this is order to get the data submited before sending the ajax call.

editor.on( 'preSubmit', function ( e, data ) {
...
});

Inside that form, I have the value data.data_key that is equal to 1 for example. I want to, before Datatables refreshes, to make this value equal to something else. How can I achieve that? I tried to do

editor.on( 'preSubmit', function ( e, d ) {
data.data_key = 3
});

But it doesn't seem to work, the refreshed Datatables contains the original value. Any idea on how can I go about this problem?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    To be clear, do you want to change the value before it's submitted to the server? Or you want to modify the data after the server responds to the submission?

    Colin

  • islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1

    @colin after the server responds, when re-writing the data to Datatables.

  • islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1

    I have tried this :

    editor.on( 'preEdit', function ( e, d ) {
        return {data_key: d.data['data_key']}
    } );
    

    But also this doesn't seem to change the updated data for the cell data_key...

  • islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1

    I found the answer while testing tons of things :smile:

    editor.on( 'preEdit', function ( e, d, data ) {
        data.data_key = 'New data key'
        return data
    } );
    

    For reference the list of events can be found here : https://editor.datatables.net/reference/event/

  • colincolin Posts: 15,118Questions: 1Answers: 2,583
    Answer ✓

    Perfect, glad all working.

This discussion has been closed.