Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

table rows expand/collapse formatting

Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a situation where I have a 'n' parent rows in a table and each parent has a 0 or more child rows. The number of columns is same in both parent and child.
I need to collapse/expand (hide/unhide) the child rows when I click on the parent row.

For this I have a outer table where each row of the table contains either the parent data or a another table with a div that has all the child rows. I can expand/collapse with a js changing the style.

However the data in the child table does not line up with the data in the parent table. How do i fix the formatting or Do I build this dataset a different way.

Please help. Thanks

[ May 30, 2008: Message edited by: Pranav Sharma ]

Ok so I have been thinking about this, Im guessing the best way to align the data is to put all of them in 1 table and then hide the rows I want. If you think this is a better way, could you give me some direction for a generic hide/show method. I dont know how to keep track of the children for each parent.

[ May 31, 2008: Message edited by: Pranav Sharma ]
Pranav Sharma
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I think I got it, dont know if its the best way to do it so please let me know if there is a better way.

I read up on the table tag at, Im using the tbody tag to group the children rows and then hidiing/showing on the tbody id.
No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic