One result, two rows (UNION ?)
One result, two rows (UNION ?)
Mairie du Pecq
Posts: 9Questions: 3Answers: 0
Hi,
I have a request that gives me data like this:
How to get 2 lines per result in datatables
Like :
I can use UNION ALL :
SELECT id, user, start_time, start_location FROM test
UNION ALL
SELECT id, user, end_time, end_location FROM test;
But how to use this for display with Datatables (2 rows for 1 result) and editable on Editor (2 rows with same id) ?
In picture
Wish in Datatables :
Wish in Editor :
Thx for your help
This question has an accepted answers - jump to answer
Answers
Anybody got any ideas or leads ?
This example from this thread should help. It's demonstrating how the data can be split into multiple records in
initComplete
,Colin
I should add to this to say that I think there are some additional complexities in this case since you are using Editor. It assumes that each row can be address uniquely in the database, which is not the case for what you describe here.
That said, I think you could do it while a child row for the second row, and a custom layout for the form.
The only part I think that might cause a little bit of extra work is that you'd need to have the child row reflect the selection state of the parent row (
tr.selected + tr
would do it) and if you want selection control on the child row, you'd need to add a click listener and then use the API to check the selection state of the host row and toggle it.Allan
Thanks for your help.
I will try to do differently.
Can i create a different custom layout for "create" and "edit" button ?
When i choose "create" => custom layout + recording of 2 row
For recording the second row do i use ?
->on( 'postCreate'
And when i choose "edit" => standard layout or new custom layout + update of 1 row
Not with the same Editor instance (at least not easily), but you could absolutely use two different Editor instances with a different template configured.
Allan