当我使用分页功能的时候,出现了问题:
下面的是正常的:
public ActionResult MyCustomer(CustomerSearchModel model) { this.InitCustomerList("我的客户", model.GradeId.HasValue ? "MyCustomer" : null, model.GradeId); model = this.InitCustomerSearchModel(model); model.RouteName = "MyCustomer"; model.IsDept = false; model.CanAssignTo = true; model.ShowGradeValues = !model.GradeId.HasValue; model.SelectModularType = ModularType.Customer; if (model.GradeId.HasValue) { model.SelectedGradeValue = model.GradeId.Value; } //model.ViewName = "MyCustomerList"; model.ForPublic = false; //model.GridCommand = null; return View("MyCustomerList", this.RunListPage(model, null)); }
MyCustomerList.cshtml:
@model CustomerSearchModel <div style="width:95%;padding-left:20px;"> @Html.Partial("_CustomerFilterList", Model) </div>
_CustomerFilterList.cshtml:
@model CustomerSearchModel @{ Layout = null; @using (Html.BeginRouteForm(Model.RouteName, new { gradeId = Model.GradeId }, FormMethod.Get, new { Id = "SearchForm" })) { <div> @Html.Partial(Model.FilterViewName ?? "_CustomerFilterView", Model) </div> <div style="margin-bottom:50px"> @Html.Partial(Model.ListViewName ?? "_CustomerListView", Model) </div> }
页码导航能使用MyCustomerList这个Action路径。
而下面的代码则出现错误,页码导航使用了CustomerList作为Action路径:
public ActionResult MyCustomer(CustomerSearchModel model) { this.InitCustomerList("我的客户", model.GradeId.HasValue ? "MyCustomer" : null, model.GradeId); model = this.InitCustomerSearchModel(model); model.RouteName = "MyCustomer"; model.IsDept = false; model.CanAssignTo = true; model.ShowGradeValues = !model.GradeId.HasValue; model.SelectModularType = ModularType.Customer; if (model.GradeId.HasValue) { model.SelectedGradeValue = model.GradeId.Value; } //model.ViewName = "MyCustomerList"; model.ForPublic = false; //model.GridCommand = null; return View("MyCustomerList", model);// this.RunListPage(model, null)); }
[ChildActionOnly] public ActionResult CustomerList(CustomerSearchModel model) { model = this.RunListPage(model, model.GridCommand); if(model.ViewName == null) { model.ViewName = "_CustomerFilterList"; } if(model.ListViewName == null) { model.ListViewName = "_CustomerListView"; } if(model.FilterViewName == null) { model.FilterViewName = "_CustomerFilterView"; } return View(model.ViewName, model); }
MyCustomerList.cshtml:
@model CustomerSearchModel <div style="width:95%;padding-left:20px;"> @Html.Action("CustomerList", "Customer", Model) </div>
没办法解决,只能通过切换回原来的环境或虚拟一个环境来达成目的。