我想把表作为数据表,但它不适用于我的表。datatable在静态表中工作,但是当im添加动态表时,它没有显示任何datatable特性,比如搜索选项和分页功能。所有记录都会及时显示,即使它在分页中选择了10。
代码
<script>
$(document).ready(function () {
$('#example').DataTable();
});
</script>
<table id="example" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>deviceid</th>
<th>status</th>
<th>UpdatedTime</th>
</tr>
</thead>
<tfoot>
<tr>
<th>deviceid</th>
<th>status</th>
<th>UpdatedTime</th>
</tr>
</tfoot>
@foreach (var item in Model)
{
<tbody>
<tr>
<td>@Html.DisplayFor(modelItem => item.deviceid)</td>
<td>@Html.DisplayFor(modelItem => item.status)</td>
<td>@Html.DisplayFor(modelItem => item.UpdatedTime)</td>
</tr>
</tbody>
}
</table>发布于 2017-10-18 18:54:36
添加以下所有
//cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css
//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js
//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js
//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js发布于 2017-10-18 11:45:49
尝试如下:
$(document).ready(function () {
$('#example').DataTable();
});发布于 2017-10-18 12:04:20
<table id="example" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>deviceid</th>
<th>status</th>
<th>UpdatedTime</th>
</tr>
</thead>
<tfoot>
<tr>
<th>deviceid</th>
<th>status</th>
<th>UpdatedTime</th>
</tr>
</tfoot>
<tbody>
@foreach (var item in Model)
{
<tr >
<td>@Html.DisplayFor(modelItem => item.deviceid)</td>
<td>@Html.DisplayFor(modelItem => item.status)</td>
<td>@Html.DisplayFor(modelItem => item.UpdatedTime)</td>
</tr>
}
</tbody>
</table>https://stackoverflow.com/questions/46808177
复制相似问题