Programmatically trigger editor.submit()

Programmatically trigger editor.submit()

Red SniperRed Sniper Posts: 52Questions: 11Answers: 0

Link to testcase:
http://live.datatables.net/gesifuqa/18/edit

Description of problem:
I have 2 tables (A and B ) , both editable with editor .
When A submits, some data are changed in table B.
I need to programmatically call editor.submit() in order to update some data on table B, even if no edits have been done on table A.

I have tried calling the api from console, but it seems that if there is no edited data, my callbacks in the submitComplete won't be triggered. (these callbacks just tell table B to read data from table A to update itself)

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    I don't actually see a call to submit() in your code. Where specifically do you want to call it?

    Allan

  • Red SniperRed Sniper Posts: 52Questions: 11Answers: 0
    edited July 2022

    Hi Allan,
    I have updated the test case.
    Before that I was doing it manually from the consolle.
    If I call the methods directly (tableB.update()), it works, ofc.
    If I call the submit() , it doesn't work the same way.

    http://live.datatables.net/gesifuqa/19/edit?js,console

    thanks for the help

  • Red SniperRed Sniper Posts: 52Questions: 11Answers: 0
    edited August 2022

    Hi Allan,

    Any thoughts on this ?
    Do you suggest to call the methods directly, or is there a way to mimic the natural flow of operations written in the submit event ?

    Thanks

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Hi,

    There doesn't appear to be a tableB.submit() method. I'd expect it to throw an error if it were called like that as such.

    Perhaps you could give me an overview of what your goal is? I'm not quite getting it I'm afraid.

    Allan

  • Red SniperRed Sniper Posts: 52Questions: 11Answers: 0

    I have updated the test case (hope it is clearer now :smile: )

    Little explanation:
    tableA and tableB contain data coming from a rest service.
    When you edit tableA (add rows, edit cell values, ecc..) tableB needs to be updated.
    Through the submitComplete of tableA editor, tableA calls the tableB.update() method that updates tableB. In my page this method makes calls to different rest services to get additional data to update the data it received from tableA (removed in test case for semplicity).

    Problem is : in some cases, the data coming from the rest service may not be complete. So when I open the page, before showing the table to the user, I should be able to manually trigger the method of tableB that would make it update itself .
    Since I wouldn't want to write more code, I thought I could trigger the submit() so that it calls the tableB.update()

    In the test case there are 2 buttons:
    - submitBtn : triggers the submit() of tableA editor (which reflects the normal flow explained above, e.g. user modifying the data of tableA), that will call the update() of tableB
    - updateBtn : triggers the update() of tableB
    -
    UpdateBtn works fine, submitBtn not.
    My guess is because there is no data being modified in tableA.
    Is there a way to mimic the submitBtn so that it triggers the submitComplete of tableA and consequentially updates tableB ? Or the explicit call to tableB.update() is the only way to go ?

    http://live.datatables.net/gesifuqa/20/edit

    Thanks Allan

Sign In or Register to comment.