How to delay submit until user clicks 'submit' button (Datatables Editor question)

How to delay submit until user clicks 'submit' button (Datatables Editor question)

draperddraperd Posts: 10Questions: 4Answers: 0

I want to allow users to inline edit multiple fields and rows in a table, then either cancel (roll all changes back) or submit (submit all changes at once). It seems like this should be something you can do, but I'm having a hard time figuring out how.

I think it should be some combination of (1) telling Editor to just close on blur (easy: that's the default) , (2) intercepting some event to update the data locally, then (3) grabbing all the data to do a submit. (1) and (3) are straight-forward I think, but (2) is where I am stuck.

Which event should I use? I tried this:

editor.on('preBlur', function(ev) { console.log(ev); });

It triggers, but I can't make any sense out of the data in the event object. Somehow I need to find the value in the form before it is closed, so I can update the table state with it.

I'm sure I'm missing something obvious --- would be grateful if anyone could clue me in...

(Not sure if it is helpful, but here's the debugger code for my test table: opodey.)

This question has an accepted answers - jump to answer

Answers

  • draperddraperd Posts: 10Questions: 4Answers: 0

    Figured it out I think --- the answer was in https://editor.datatables.net/examples/advanced/localstorage.html. It didn't occur to me to override ajax, but that does exactly what I need.

  • allanallan Posts: 63,791Questions: 1Answers: 10,513 Site admin
    Answer ✓

    Hi,

    Good to hear you found a solution. You are right that Editor doesn't provide its own queuing mechanism at the moment, so each inline edit needs to be submitted. You can override that using the ajax option and some clever queuing code that will buffer your changes and allow them to be submitted.

    Queuing is something I hope to introduce into Editor core in a future version.

    Regards,
    Allan

  • dwithnalldwithnall Posts: 4Questions: 1Answers: 0

    I would personally very much appreciate a queuing feature.
    I am building a datatable/editor combo which allows users to make a series of changes (add/edit/delete) and then commit the changes in one go.

  • jaredgalanisjaredgalanis Posts: 1Questions: 0Answers: 0

    This is helpful, how though, would you perform an ajax override if using Editor's inline editing feature?

  • allanallan Posts: 63,791Questions: 1Answers: 10,513 Site admin

    The inline editing uses the same Ajax options as the full form editing - there is no distinction between them. ajax is the property that controls Editor's Ajax behaviour.

    Allan

This discussion has been closed.