Parent / child editing: Parent table needs to show child table information
Parent / child editing: Parent table needs to show child table information
![szakendre](https://secure.gravatar.com/avatar/b4b2bcff8a58d8a35cf963680dc1511d/?default=https%3A%2F%2Fvanillicon.com%2Fb4b2bcff8a58d8a35cf963680dc1511d_200.png&rating=g&size=120)
Hello!
I made a parent / child solution based on this example:
https://editor.datatables.net/examples/advanced/parentChild.html
The parent table shows the order projects, the child shows the elements of the choosen order.
Each element has price and quantity.
How can I show the summarized price of elements on the parant table?
ajax:
{
url: 'ajax/pr1.php',
type: "POST"
}
$editor = Editor::inst( $db, 'pr', 'id' )
->fields(
...
);
$editor->process( $_POST );
$editor->json();
Thank You and best regards:
Endre, Szak
This discussion has been closed.
Answers
Are you looking for something like the FooterCallback example? If so you can change it to sum the columns of the child table instead of the parent.
Kevin
Hi Kevin,
I need a different solution. For the summary value I have to run an SQL query on the server side.
If I have the variable, how can I modify the AJAX answer to send this extra information? I mean can I insert a plus variable to POST data?
Thanx
You can use the
ajax.data
option to send extra info. Guessing you want to run the SQL query when fetching the child table? If so add it here (from the example you linked):Kevin
Hello Kevin,
Thank you, this part is working, I can send extra variable from JS to PHP.
Now I have to send extra datas from PHP to JS.
Do you have any idea how to do that?
Thank You and best regards:
Endre, Szak
This thread here might help, it's showing that,
Colin
I couldn't solve the problem with this method, so I did a workaround:
With postCreate and postEdit I made a function that update the datas of the parent table. Then I force a reload upon any changes, so it did the trick.
Thank you!