Copy information in 2 tables
Copy information in 2 tables
Is it possible to record identical data on 2 different tables while maintaining
visualization in the table of a single table with datatable editor.
example : datatable editor with database->table Car1
-------------
- car 1 -
-------------
-ID
-couleur
-marque
-modele
-nombre de place
-nombre de porte
-equipements
-type
-usage
and if validate a new entry in table Car1 with datatable editor, datatable create a copy in table Car2 :
Don't play the information of car2 in datatable editor (just copy information in other table)
-------------
- car 2 -
-------------
-ID
-couleur
-marque
-modele
-usage
It is possible ?
Thanks for your Help.
This discussion has been closed.
Replies
Hi @SWATswat ,
I don't fully understand, but this example here may help. It shows how items can be transferred from one table to another.
Cheers,
Colin
You might want to try a postCreate event:
https://editor.datatables.net/reference/event/postCreate
hello,
I'd just like to copy some information from first table SGBD (view for datatable) into the seconde table SGBD (not seen by datatable) when creating a row in à first table SGBD.
sorry for my bad english.
Hello,
I want to duplicate some data of the line I just created in a second table with -> on (postCreat ...), but it does not work with the code below.
I get this error:
Certainly, I do not use this function properly.
for information, if I remove the block -> on (postCreat ...), the script works perfectly.
Can you help me please.
Using a server-side
postCreate
event is how I would suggest you do it.Your reply above says you are getting invalid JSON in return from the server. What is being sent back? Is there an error message indicating what might be going wrong? If not there, then having a look in the server's error logs. I don't immediately see what would be wrong there, but the error message will hopefully clarify what is going on.
The other option is to use a database trigger, which might be quite attractive if data can be inserted from somewhere other than Editor.
Allan
Hello Allan,
After correcting the line 52 with an addition of ")" and passage in ServerSide, it works very well.
Is it possible to do the same process with postEdit and UPDATE and a WHERE condition see the code below? (this example is wrong it's just for the idea)
Thanks for in advance
Hello Allan,
I reformulate, what is the good format for embedding a where clause in Postedit ?
Thanks for your help.
The third parameter for the
->update()
method can be used as thewhere
condition.Allan