Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Design Having trouble with an accordion table using Bootstrap…

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #247049
    sweetdiss
    Participant

    Long time reader, first time poster!

    I’m trying to create a table that reveals and hides additional rows of information, accordion-style. It’s working for the most part, but unfortunately the cell layout gets all screwed up whenever you reveal a row.

    http://jsfiddle.net/3y7118ek/

    As you can see, when you click a row, all the new cells become compressed to the left instead of stretching out across the row like normal. I’ve been trying to debug in Chrome but I can’t figure out why it’s doing this.

    “`
    <table id=”tbl-sample-values” class=”table table-condensed table-bordered table-hover” style=”font-size:85%;”>
    <thead>
    <tr style=”color: red;”>
    <th>Step #</th>
    <th>Processing Step</th>
    <th>Barcode</th>
    </tr>
    </thead>

            &lt;tbody&gt;
    
                &lt;tr data-toggle="collapse" data-target="#accordion" class="clickable"&gt;
                    &lt;td&gt;9&lt;/td&gt;
                    &lt;td colspan="2"&gt;Parts Inspection&lt;/td&gt;
                &lt;/tr&gt;
    
                &lt;tr id="accordion" class="collapse"&gt;
                    &lt;td&gt;9.1&lt;/td&gt;
                    &lt;td&gt;Handle silicon electrodes...&lt;/td&gt;
                    &lt;td&gt;[Barcode here]&lt;/td&gt;
                &lt;/tr&gt;
    
                &lt;tr data-toggle="collapse" data-target="#accordion2" class="clickable"&gt;
                    &lt;td&gt;10&lt;/td&gt;
                    &lt;td colspan="2"&gt;IPA Clean&lt;/td&gt;
                &lt;/tr&gt;
    
                &lt;tr id="accordion2" class="collapse"&gt;
                    &lt;td&gt;10.1&lt;/td&gt;
                    &lt;td&gt;Place part with frontside facing up...&lt;/td&gt;
                    &lt;td&gt;[Barcode here]&lt;/td&gt;
                &lt;/tr&gt;
    
            &lt;/tbody&gt;
        &lt;/table&gt;
    

    `

    Thanks!

    #247051
    Beverleyh
    Participant

    when you click a row, all the new cells become compressed to the left instead of stretching out across the row like normal

    The demo isn’t exhibiting this behaviour so it’s difficult to comment. Looks like you forgot the JavaScript that reveals the cells.

    #247053
    Shikkediel
    Participant

    It’s relying on a Bootstrap script, Beverley. I think sweetdiss is referring to the inline behaviour of the submenu td text. So rather than being “compressed”, it’s not taking up the full width. Not a clue myself how to fix that by the way.

    #247055
    Beverleyh
    Participant

    OK – I didn’t see the script inclusion from my iPhone when I checked this morning. The click-to-reveal doesn’t work there or in IE11 (and I’m having trouble booting up my Edge machine at the mo to can’t check there either).

    Tip: Add an empty onclick attribute to .clickable tr element to make it work in iOS

    From what I can see in Chrome, display:block; is applied to the row to make it visible, but that isn’t playing nicely with the table cells (making them collapse). For those it should be display:table-row;

    tr.collapse.in { display:table-row; } in your stylesheet should hopefully fix it.

    #247075
    sweetdiss
    Participant

    Thanks! That worked great.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design’ is closed to new topics and replies.