如何使用asp.net對錶進行排序/過濾?我不確定如何去做,我必須使用jQuery。研究,但我沒有看到如何處理這個問題。在asp.net中排序表mvc
<table>
<tr>
<th class="col-lg-3 tablehead">Expense Account</th>
<th class="col-lg-3 tablehead">Description</th>
<th class="col-lg-3 tablehead">Requisition Number</th>
<th class="col-lg-3 tablehead">Item Number</th>
</tr>
@for (int i = 0; i < Model.Count; i++)
{
<tr>
<td>@Html.CheckBoxFor(m => m[i].postTrnx)</td>
@* <td class="label">@Html.DisplayFor(m => m[i].requisitionNumber) </td>*@
@*<td class="label">@Html.DisplayFor(m => m[i].transactionDate)</td>*@
</tr>
foreach (var item in Model[i].items)
{
@Html.HiddenFor(m => item.description)
@Html.HiddenFor(m => item.expense_account)
@Html.HiddenFor(m => item.itemNumber)
<tr>
<td class="col-lg-3 tabledata">@item.expense_account.account_desc</td>
<td class="col-lg-3 tabledata">@item.description</td>
<td class="label">@Html.DisplayFor(m => m[i].requisitionNumber) </td>
<td class="col-lg-3 tabledata">@item.itemNumber</td>
<td class="col-sm-1 tabledata">@item.quantity</td>
<td class="col-sm-1 tabledata">@item.selecteduomtext </td>
<td class="col-sm-1 tabledata">@item.price</td>
<td class="col-sm-1 tabledata">@item.extended_cost</td>
<td class="label">@Html.DisplayFor(m => m[i].transactionDate)</td>
<td>@Html.ActionLink("Edit", "Edit", new { id = @item.lineNum, name = Model[i].docNumber })</td>
</tr>
}
}
</table>
你想在頁面加載時進行默認排序嗎?或者你希望用戶能夠在頁面加載後動態排序?或兩者? – mason
您可以使用DataTables https://datatables.net/。默認配置支持過濾和排序。 這是客戶端,但很好。 – Waragi
@Waragi他使用Bootstrap來判斷類。 [FooTable](HTTP://fooplugins.github。io/FooTable /)比使用Bootstrap的DataTable更好。 – mason