Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create nested cells inside the same table TD

Tags:

html

razor

I have the following table:-

<table class="table table-striped">
    <thead>
        <tr>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach(var permisionMag in Model.PermisionManagement)
        {
            <tr>
                <td>@permisionMag.Name</td>
                @{
                    int i = 0;
                    <td class="f">
                        @foreach(var item in permisionMag.TechnologyTypes.OrderBy(a => a.Name)) {
                            @(i+1)  @item.Name  
                            i = i + 1;
                        }
                        <br />           
                    </td>
                }
            </tr>
        }
    </tbody>
</table>

But currently i need the second column to have nested rows instead of showing the rows inside the same TD? any advice on this?

like image 700
john Gu Avatar asked Aug 13 '13 13:08

john Gu


People also ask

Can you nest a table within a table?

Tables can be nested together to create a table inside a table. To create a nested table, we need to create a table using the <table> tag. This table is known as the outer table. The second table that will be nested table is called the inner table.

How do you create a sub table inside a main table?

A table can be created within another table by simply using the table tags like <table>, <tr>, <td>, etc., to create our nested table. Since nesting tables can lead to higher complexity levels, remember to begin and end the nesting tables within the same cell.

How do you make a nested table?

Click inside any cell in the larger table. Once again, use the “Insert” tab to create a table. For example, click on cell 1, go to “Insert,” “Table” and then create a 2-by-2 table. This 2-by-2 is now nested inside of the 3-by-3.

Can we have nested TR?

tr can only be a child of a table , thead , tfoot , etc.


1 Answers

You can not generate directly table cells, you have to generate a new table inside the second table cell. You could also render @item.Name as a span/div and style that to create the illusion of a nested table(jsFiddle example).

like image 162
Valentin D Avatar answered Oct 11 '22 14:10

Valentin D