行分组在JQuery Datatables中不起作用

时间:2015-01-01 13:40:19

标签: jquery asp.net-mvc datatable

我试图在JQuery Datatable中添加行分组,如下所示。我想根据第一栏进行分组。

<table class="table table-bordered table-hover Devices" id="Devices">
    <thead style="color:white">
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.AssetId)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.MobileDevice)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.DeviceHolder.DeviceHolderName)
            </th>
       </tr>
    </thead>

<tbody style="color:black">

        @foreach (var item in Model)
        {

            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.AssetID)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.MobileDevice)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DeviceHolder.DeviceHolderName)
                </td>
           </tr>
        }
    </tbody>
$(document).ready(function () {
        $('#Devices').dataTable({ "bLengthChange": false, "bPaginate": false })
                .rowGrouping({
                    iGroupingColumnIndex: 0,
                    bExpandableGrouping: true


                });
    });

但它根本不起作用。如果此代码有任何问题,请帮助我。

1 个答案:

答案 0 :(得分:-1)

尝试使用<tablename>.fnDraw();

刷新您的表格