Inserting multiple rows based on data in the "added" row on the server side
Inserting multiple rows based on data in the "added" row on the server side
I have a column in each new row that contains a set of dates.
The requirement is to create an additional row for each of those dates after the original row is inserted successfully.
I want to do this on the server side using postCreate event by looping thru the list of dates in the new row and inserting an additional row.
Is there an example of doing additional SQL actions (INSERT preferred) within an event on the server side?
Are there any public methods in the Datatables Editor PHP libraries to assist with this?
Finally, how do I cause the the Datatables list to be rebuilt on the webpage (so the additional rows are included) or is this automatic?
Regards,
Jim
This question has an accepted answers - jump to answer
Answers
Hi Jim,
The
Database->insert()
method from the libraries will help here. The developer documentation for it is available here. Basically you just need to give it the table name to insert into and an array of key value pairs for the columns and values.To have the DataTable update with the newly inserted data, since Editor doesn't "know" about the new row, you need to use
ajax.reload()
in thesubmitComplete
client-side event.Regards,
Allan