我正在创建具有分页功能的新DevExpress GridView,但是单击其他页面的链接不会执行任何操作。我需要添加此功能,但是我不确定从哪里开始。
新的DevExpress GridView基于不使用DevExpress的视图。此页面将是公司目录的列表,因此它包含诸如名称,电话和位置之类的列。该视图已创建,并显示带有分页控件。我已经在DevExpress论坛上四处寻找类似问题,但是这些问题都使用.aspx,而我的GridView使用的是.cshtml。
public ActionResult DevExpressView()
{
return View(EmployeeList);
}
@Html.DevExpress().GetStyleSheets(new StyleSheet { ExtensionSuite = ExtensionSuite.GridView})
@Html.DevExpress().GridView(
settings =>
{
settings.Name = "GridView";
settings.CallbackRouteValues = new { Controller = "DevExpessController", Action = "DevExpressView" };
settings.KeyFieldName = "Clock";
settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
settings.SettingsPager.PageSize = 32;
settings.Settings.VerticalScrollBarMode = ScrollBarMode.Visible;
settings.Settings.VerticalScrollableHeight = 350;
settings.ControlStyle.Paddings.Padding = System.Web.UI.WebControls.Unit.Pixel(0);
settings.ControlStyle.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
settings.ControlStyle.BorderBottom.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
settings.Columns.Add("FirstName");
settings.Columns.Add("LastName");
settings.Columns.Add("Department");
settings.Columns.Add("Title");
settings.Columns.Add("PlantNO");
settings.Columns.Add("Telephone");
settings.Columns.Add("Mobile");
settings.Columns.Add("Pager");
}).Bind(Model).GetHtml()
在GridView的底部有控制分页的控件,但是单击它们时什么也没有发生。我希望这些控件可以更改正在显示的员工页面。抱歉,如果我的问题没有道理,我是DevExpress的新手。
答案 0 :(得分:1)
对于DevExpress服务器端控件,仅具有一个Controller Action是不够的。 您需要2个Controller Actions,1个View和1个PartialView才能起作用。 还要确保为GridView加载脚本(见下文)。
客户端导航至:
public ActionResult DevExpressView()
{
IQueryable<Employee> model = GetYourDataFromSomewhere();
return View("EmployeeList", model);
}
EmployeeList.cshtml(查看)
@model IEnumerable
@Html.DevExpress().GetScripts(new Script { ExtensionSuite = ExtensionSuite.GridView })
@Html.DevExpress().GetStyleSheets(new StyleSheet { ExtensionSuite = ExtensionSuite.GridView})
@Html.Partial("GridView", Model)
GridView.cshtml(部分视图)
重要:此视图仅需要包含网格。没什么!
@Html.DevExpress().GridView(
settings =>
{
settings.Name = "GridView";
settings.CallbackRouteValues = new { Controller = "DevExpessController", Action = "DevExpressViewPartial" };
settings.KeyFieldName = "Clock";
settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
settings.SettingsPager.PageSize = 32;
settings.Settings.VerticalScrollBarMode = ScrollBarMode.Visible;
settings.Settings.VerticalScrollableHeight = 350;
settings.ControlStyle.Paddings.Padding = System.Web.UI.WebControls.Unit.Pixel(0);
settings.ControlStyle.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
settings.ControlStyle.BorderBottom.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
settings.Columns.Add("FirstName");
settings.Columns.Add("LastName");
settings.Columns.Add("Department");
settings.Columns.Add("Title");
settings.Columns.Add("PlantNO");
settings.Columns.Add("Telephone");
settings.Columns.Add("Mobile");
settings.Columns.Add("Pager");
}).Bind(Model).GetHtml()
表格的回调操作:
public ActionResult DevExpressViewPartial()
{
IQueryable<Employee> model = GetYourDataFromSomewhere();
return PartialView("GridView", model);
}
看看他们的demo。如果您复制该代码(当然,除了NorthwindDataProvider之外),则应该有一个有效的示例。