【发布时间】:2017-10-30 13:22:23
【问题描述】:
在 asp.net-core 控制器中,我按 BirthDate 属性对模型集合进行降序排序并将其返回到视图。虽然调试准备好的顺序得到尊重,但在显示视图表之前再次将排序方向更改为升序。
有没有办法通过在 Razor 视图中应用 Bootstrap 类来设置表格列的默认排序顺序从升序到降序?
<table id="table" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>Birth date</th>
<th>Name</th>
</tr>
</thead>
<tbody>
@foreach (var person in Model)
{
<tr>
<td>@person.BirthDate</td>
<td>@person.Name</td>
</tr>
}
</tbody>
</table>
最简单的方法是什么?
【问题讨论】:
-
Bootstrap 不支持。但是您可以为此使用一些插件。 tutsme-webdesign.info/bootstrap-3-sortable-table, stackoverflow.com/questions/31888566/…
标签: twitter-bootstrap razor asp.net-core-mvc