如何在MVC中的表中实现bootstrap手风琴?

时间:2018-05-23 03:05:34

标签: asp.net-mvc twitter-bootstrap-3

我想在我的应用程序中实现bootstrap手风琴。目前,如果我点击任何行,它会先给我#include <iostream> #include <Windows.h> #include <conio.h> using namespace std; const int width = 60; const int height = 20; int x, y; int zombX, zombY; void Setup() { x = width / 2; y = height / 2; zombX = rand() % width; zombY = rand() % height; } void Draw() { system("cls"); for (int i = 0; i < width + 2; i++) cout << "*"; cout << endl; for (int i = 0; i < height; i++) //i = height { for (int j = 0; j < width; j++) { if (j == 0) cout << "*"; if (i == y && j == x) cout << "I"; else if (i == zombY && j == zombX) cout << "Z"; else { bool print = false; if (!print) cout << " "; } if (j == width - 1) cout << "*"; } cout << endl; } for (int i = 0; i < width + 2; i++) cout << "*"; cout << endl; } @Html.Raw(item.D)

我想要的是,如果我点击第二行,则应显示其各自的@Html.Raw(item.B)@Html.Raw(item.D),依此类推。

请建议我哪里出错了。

@Html.Raw(item.B)

1 个答案:

答案 0 :(得分:1)

您需要唯一地指定ID,为此您需要将原始ID(或每行唯一的内容)附加到iddata-target属性,

      <div class="panel-body">      
            <table class="table">

                @foreach (var item in Model)
                {

                    <tr class="accordion-toggle" data-toggle="collapse" data-target="#12345-cores@(item.id)">
                        <td align="left">
                            @Html.Raw(item.H)
                        </td>                                                        
                        <td align="right">
                           @Html.Raw(item.E)
                          </td>
                            </tr>
                            <tr>
                                <td class="accordion-body collapse" id="12345-cores@(item.id)">

                                       <table>
                                           <tbody>
                                               <tr>
                                                   <td>
                                                       @Html.Raw(item.D)
                                                   </td>
                                                   <td></td>
                                                   <td>
                                                       @Html.Raw(item.B)
                                                   </td>
                                               </tr>

                                           </tbody>
                                       </table>


                                </td>
                            </tr>
                    }

            </table>

已更新:data-target="#12345-cores@(item.id)&amp; id="12345-cores@(item.id)"