0

我有一个弹出 jQuery 对话框的 ASP.NET MVC 应用程序。在对话框中,我有一个从控制器获得的模型动态构建的表:

这是对话表html:

<script type="text/javascript">
    $(function () {

        $('#btnslide').click(function () {

        });

        $('#dtnotes tr').click(function () {

            var noteUid = $(this).attr("noteuid");

            //*******
            // here somehow i need to filter my @Model to get the item 
            // and then update my DIV 'slideinner' with the details data.
            //*******

            $(".slideinner").slideToggle();
        });

    });
</script>


<div class="widget widget-table">
    <div class="widget-header">
        <span class="icon-list"></span>
        <h3 class="icon chart">
            Notes</h3>
    </div>
    <div class="widget-content">


        <table id="dtnotes" class="table table-bordered table-striped data-table">
            <thead>
                <tr>
                    <th>
                        Subject
                    </th>
                    <th style="width: 70px;">
                        Type
                    </th>
                    <th style="width: 70px;">
                        UserName
                    </th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model)
                {
                    <tr class="gradeA" noteuid="@item.NoteUid">

                        <td>
                            @item.Subject
                        </td>
                        <td>

                            @item.NoteTypeDesc

                        </td>
                        <td nowrap>
                            @item.UserName
                        </td>

                    </tr>
                }
            </tbody>
        </table>

        <button id="btnslide">slide it</button>
    </div>
    <!-- .widget-content -->
</div>
<div class="slideinner">
    <p>Subject</p>
    <p>Body</p>
</div>
<!-- .widget -->

我在底部还有一个 div,它是一个幻灯片 div。因此,当用户单击表格行时,div 会向上滑动。

我想要的是单击该表行,DIV 必须显示来自我的模型项的额外详细信息。

所以我想我必须能够从表行“item.NoteUid”键中获取模型项目,然后使用 jquery 更新带有项目模型数据的“slideinner”div。

希望可以有人帮帮我。欣赏

4

1 回答 1

0

You can render all the model data you need in the table body and hide the ones you need to with css display:none. I hid the @model.body value in a so you can so retrieve with jquery

$('#dtnotes tr').click(function () {

            var noteUid = $(this).attr("noteuid");

            //*******
            $('.slideinner > p.body').html($(this).children('.body').html());
           $('.slideinner > p.subject').html($(this).children('.subject').html());

            //*******

            $(".slideinner").slideToggle();
        });



 <tbody>
                @foreach (var item in Model)
                {
                    <tr class="gradeA" noteuid="@item.NoteUid">

                        <td class="subject">
                            @item.Subject
                        </td>
                         <td class="body" style="display:none;">
                                @item.Body
                            </td>
                        <td class="notetypedesc">

                            @item.NoteTypeDesc

                        </td>
                        <td nowrap>
                            @item.UserName
                        </td>

                    </tr>
                }
            </tbody>

<div class="slideinner">
    <p class="subject">Subject</p>
    <p class="body">Body</p>
</div>
于 2013-07-14T08:22:01.543 回答