2 SQL tables to produce alternating datables rows? Is this possible
2 SQL tables to produce alternating datables rows? Is this possible
I have 2 identically structured tables in SQL. 1 is a table of budget items by project type. The 2nd is a table of multiple projects for each type, and the associated dollars spent per project. I want to display a table which has alternating rows thus:
Type1Budget Jan Feb Mar...
Type1Actuals Sum for Jan Sum for Feb sum for Mar...
Then 2 rows for type2 projects and so on.
Obviously, I can extract the data (in a php loop) for each SQL table, and use php to build the array for json
It just seems in-elegant.
Is there a clever way to handle this using the php library?
Alternately, can DataTables take a single JSON "row" and display it as 2 rows in the HTML?
Thanks for any thoughts on this!
This question has an accepted answers - jump to answer
Answers
Maybe row grouping will do what you want:
https://datatables.net/blog/2017-04-07
Or Child rows:
https://datatables.net/examples/api/row_details.html
Kevin
You also may want to take a look at this recent blog entry, which takes the child rows example a little further.
https://datatables.net/blog/2017-03-31
Thanks - child rows are the trick....
Row grouping is quite interesting - Thanks for bringing that new feature to my attention!