我已经实现了一个WebGrid.排序,分页和过滤不能一起使用.它们在您单独使用时起作用.当您将三者结合使用时,过滤不起作用.
症状:
过滤结果集,然后排序.
要么
过滤结果集,然后转到下一页.
在这两种情况下,过滤器都会丢失.但它确实是页面和排序.
在后面的代码中:当通过排序或分页调用action方法时,为每个过滤器参数显示null.
通过过滤器调用操作方法时,过滤器参数会通过.
这告诉我,当你开始排序或分页时,它没有提交表单.
public ActionResult MyPage(int? page, int? rowsPerPage,
string sort, string sortdir,
string orderNumber, string person, string product)
Run Code Online (Sandbox Code Playgroud)
我在SO和其他地方环顾四周.有很多例子和人们会问如何做一个或另一个或全部三个.但我只看到一个与我的问题,所以我在这里发布.(他也没有解决)
我的页面实现如下:
@using (Ajax.BeginForm("MyPage", null, new AjaxOptions { InsertionMode = InsertionMode.Replace, UpdateTargetId = "myGrid" }, new { id = "filter" }))
{
<div class="right">
<select id="rowsPerPage" name="rowsPerPage">
<option>15</option>
<option>25</option>
<option>50</option>
<option>75</option>
<option>100</option>
</select>
</div>
<div class="table">
<div class="tableRow">
<div class="tableCell">
Order Number
</div>
<div class="tableCell">
Person
</div>
<div class="tableCell">
Product
</div>
</div>
<div …Run Code Online (Sandbox Code Playgroud)