刷新数据表并在使用jQuery将数据注入其中时使用其功能

时间:2016-12-23 22:08:55

标签: javascript jquery html asp.net datatables

在jquery post上将信息注入表本身后,我尝试使用数据表功能。表的HTML标记是:

<table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap dataTable no-footer dtr-inline" cellspacing="0" width="100%" role="grid" aria-describedby="datatable-responsive_info" style="width: 100%;">
                <thead>
                    <tr role="row">
                        <th class="sorting" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" style="width: 70px;" aria-label="First name: activate to sort column ascending">Store Name</th>
                        <th class="sorting_asc" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" style="width: 268px;" aria-label="" aria-sort="ascending">Comment</th>
                        <th class="sorting_asc" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" style="width:18px;" aria-label="Last name: activate to sort column descending" aria-sort="ascending">Your Rating</th>
                        <th class="sorting_asc" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" style="width: 18px;" aria-label="Last name: activate to sort column descending" aria-sort="ascending">Seller Feedback</th>
                        <th class="sorting_asc" tabindex="0" aria-controls="datatable-responsive" rowspan="1" colspan="1" style="width: 18px;" aria-label="Last name: activate to sort column descending" aria-sort="ascending">Delete</th>
                </thead>
                <tbody>
@if (ViewBag.Products != null)
{
                    foreach (var item in ViewBag.Products)
                    {
                        <tr role="row" class="odd">
                            <td class="" tabindex="0">@item.SaleNumber</td>
                            <td class="sorting_1">@item.SaleNumber</td>
                            <td class="sorting_1">@item.SaleNumber</td>
                            <td class="sorting_1">@item.SaleNumber</td>
                            <td class="sorting_1 deleteAction"><i class="fa fa-close"></i></td>
                        </tr>
                    }
}
                </tbody>
            </table>

该表在页面加载时最初为空...这是我在帖子完成后将数据注入表中的地方:

   var dbtb = $('<table />').append(data).find('#datatable-responsive').html();
                                   $('#datatable-responsive').html(dbtb); 

但桌子完全没有反应,我无法使用它的任何功能,有没有办法让它知道我把数据注入其中?

0 个答案:

没有答案