我正在使用asp.net mvc5
网络应用程序,我需要在同一视图中显示多个WebGrids
,因此我使用Html.Action
返回部分视图,其中每个部分视图视图包含一个WebGrid
。
主要观点如下:
@model SkillManagementTDMGroup.Models.Skill
@{
ViewBag.Title = "Details";
}
<h3>Skill Details</h3>
@Html.Action("GetStaffSkills", "Skill", new {skillpre = Model.SkillID})</div>
@Html.Action("GetSkillCustomer", "Accounts", new {customermasterDetail = Model.SkillID})</div>
@Html.Action("GetStaffForSkill", "Staff", new {staffmasterdetails = Model.SkillID})</div>
每个@Html.action
调用都会调用一个动作方法,该方法呈现包含WebGrid
的部分视图,如下所示:
public ActionResult GetSkillCustomer(string customerfilter = null, int customerpage = 1, int? customerpageSize = null, string customersort = "Name", string customersortdir = "ASC", int? customermasterDetail = null)
{
var records = new PagedList<Customer>();
records.currentfilter = customerfilter;
records.Content = unitofwork.CustomerRepository.GetCustomerForGrid(customerfilter, customerpage, customerpageSize.Value, customersort, customersortdir, false, customermasterDetail).ToList();
// Count
records.TotalRecords = unitofwork.CustomerRepository.GetCustomerForGridCount(customerfilter, false, true, customermasterDetail);
records.CurrentPage = customerpage;
records.PageSize = customerpageSize.Value;
records.masterDetail = customermasterDetail;
return PartialView("_gridCustomer", records);
}
现在一切都在功能方面运行良好,我可以分别对每个WebGrids
进行排序,分页和过滤。但事情的工作方式效率不高,因为我要说我在WebGrids
之一进行排序,然后这将导致调用整个动作链方法,尽管我只需要更新单个{ {1}}。所以,如果我正确地做事,有人可以告诉我吗?或者有更好的办法吗?