Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create nested collapsible tables using Angular

I'm displaying a table that consists of all of the events a specific team as attended in a given year. Each row of the table gives some general stats for a single event (seed, placement, etc). When I click on any given row, I want to expand a nested table that shows all the games from that specific event.

I'm having some issues with the formatting. Right now when I expand the new table, it reformats the parent table in a strange way and all of the nested table columns only stretch across the first of the parent table. How can I make it the same width of the parent table?

Here is an example

and here is a screenshot of the more pretty formatted table in case the stackblitz example is hard to see.

Collapsed: enter image description here

Expanded: enter image description here

like image 464
bmorgs Avatar asked Nov 25 '25 19:11

bmorgs


2 Answers

You need to place your nested table in a tr and td with a colspan="4"

See the updated example: https://stackblitz.com/edit/angular-ivy-wnr2qn-nested-table

like image 120
Yannick Beauchamp-H Avatar answered Nov 27 '25 09:11

Yannick Beauchamp-H


Full code. Just change ng-container for a tr.

Full code: https://stackblitz.com/edit/angular-ivy-kutwtd

Example live: Here

IMAGES EXAMPLE

enter image description here

enter image description here

like image 37
Guiditox Avatar answered Nov 27 '25 09:11

Guiditox



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!