【发布时间】:2018-08-28 09:28:12
【问题描述】:
我在我的项目中使用 JQuery 数据表。
我有 ActionResult 并正在获取数据。我想在表格中显示数据,但如果我使用 tbody,数据表格的样式看起来不像普通表格。
我尝试不使用数据并编写自定义 tbody 和 tr 标签。我的问题是继续。我哪里错了?
操作结果
public ActionResult YayinEvleri()
{
dbContext = new DatabaseContext();
var yayinEvleri = dbContext.YayinEvi.ToList();
return View(yayinEvleri);
}
查看
@model List<KitapFuari.Models.Yayinevi>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js "></script>
<script>
$(document).ready( function () {
$('#yayinEvleri').DataTable();
});
</script>
<table id="yayinEvleri" class="table table-striped table-bordered" style="width:100%" cellspacing="0">
<thead>
<tr>
<th>Yayın Evi</th>
<th>Yazar</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@item.Ad</td>
</tr>
}
</tbody>
</table>
【问题讨论】:
-
请阅读 datatables.net 在您的代码中使用数据表
-
我看过这个页面。我以前用过数据表。