Sub-Tables in Bootstrap

Asked

Viewed 309 times

0

I’m creating a conventional table, which when clicked on in the group name it shows a sub-table containing the same columns and refactoring the results:

NORMAL STATE:

 GRUPOS    QUANTIDADE
|  GA   |  |  1000  |
|  GB   |  |  1600  |

WHEN CLICKED ON THE GROUP TITLE:

 GRUPOS    QUANTIDADE
|  GA   |  |  1000  |
| CLI01 |  |  500   |
| CLI02 |  |  500   |

|  GB   |  |  1600  |
| CLI01 |  |  800   |
| CLI02 |  |  800   |

FROM A TABLE STRUCTURE BELOW, WHAT IS NECESSARY TO APPLY IN ORDER FOR THE SUB-TABLES TO APPEAR AND FOR THEM TO HAVE THIS 'SHOW/HIDE' EFFECT'?

  <table class="table table-striped">
    <thead>
      <tr>
        <th>GRUPOS</th>
        <th>QUANTIDADE</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>GA</td>
        <td>1000</td>
      </tr>
      <tr>
        <td>GB</td>
        <td>1600</td>
      </tr>
    </tbody>
  </table>

1 answer

1


I don’t know if you want a treetable, but it will follow the same context.

$('ul li span').on('click', function(){
        $('.show').slideToggle();
});
.show{
    display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
        <li>
            <span>A</span>
            <div class="show">VVVV</div>
              
        </li>
    </ul>

Follow this example, if it doesn’t work, or whatever you want, post your current code, which we start from it.

  • It’s exactly what I need. I’m just not getting the snippets you’ve commented on on a page that works. What goes inside <script> </script>? Where do I put the ". show{ display: None; }"

  • I got :) thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.