我有MVC模式表它看起来像这样:如何在html表MVC中给出序列号?使用CSS或jQuery的
<table id="example" class="table table-hover">
<thead>
<tr>
<th>SL NO
</th>
<th>Designation Name
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
//Here I want Serial No here [I used Paging]
</td>
<td>
@Html.DisplayFor(modelItem => item.desigantionName)
</td>
<td>
<div class="btn btn-default btn-lg disabled p-x-2">@Html.ActionLink("Edit", "Edit", new { id = item.desigantionId }) </div>
<div class="btn btn-default btn-lg disabled p-x-2">@Html.ActionLink("Details", "Details", new { id = item.desigantionId }) </div>
<div class="btn btn-default btn-lg disabled p-x-2">@Html.ActionLink("Delete", "Delete", new { id = item.desigantionId })</div>
</td>
</tr>
}
</tbody>
</table>
上面的代码中第一栏我想序列号我用SL没有用CSS,但问题是进入下一个页面索引SL在没有resart高达1 每个寻呼机我用5行我需要启动第二页索引sl没有达到6
如何检索模型?获取模型数据时必须注意偏移量。你可以在模型中添加一些索引吗? – derpirscher
你的问题几乎没有意义。你怎么可能使用jQuery或CSS来渲染出序列号?除非你的意思是'索引',或者你只是想要每个项目的序列号,比如'1,2,3,4, 5,6,7,8'(在这种情况下@derpirscher说,你必须知道偏移量)? 如果你确实指的是序列号,它必须是你正在渲染的项目的一个属性,它必须是唯一的,所以你不能在前端简单地生成它,它与分页没有任何关系。为什么你不能渲染'item.serialNumber'或者其他什么属性被调用? –
DanCouper