我有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