devExpress 使用 GridView 嵌套 GridView 数据编辑时,第一层GridView能正常编辑数据,但是第二层GridView点击 New 时却一直在加载。
代码如下:
我所指的第一层GridView
文件名:EditModesPartial.cshtml
代码:
@using DevExpress.Web.Mvc
@using DevExpress.Web.Mvc.UI
@{
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
var grid = Html.DevExpress().GridView(
settings =>
{
settings.Name = "grid";
settings.CallbackRouteValues = new { Controller = "EditorialStaff", Action = "EditModesPartial" };
settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "EditorialStaff", Action = "AddLocalClass" };
settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "EditorialStaff", Action = "UpdateLocalClass" };
settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "EditorialStaff", Action = "DeleteLocalClass" };
settings.SettingsEditing.Mode = DevExpress.Web.ASPxGridView.GridViewEditingMode.Inline ;
settings.SettingsBehavior.ConfirmDelete = true;//删除确认
settings.Width = 900;
settings.CommandColumn.Visible = true;
settings.CommandColumn.ShowNewButton = true;
settings.CommandColumn.ShowEditButton = true;
settings.CommandColumn.ShowDeleteButton = true;
settings.KeyFieldName = "LcID";
settings.Columns.Add(column => {
column.FieldName = "LcName";
column.Caption = "栏目名";
});
settings.Columns.Add(column => { column.FieldName = "LcRemark"; column.Caption = "备注"; });
settings.SettingsDetail.AllowOnlyOneMasterRowExpanded = false;
settings.SettingsDetail.ShowDetailRow = true;
settings.SettingsBehavior.AllowFocusedRow = true;
settings.SetDetailRowTemplateContent(c => {
Html.RenderAction("RemoteClassPartial", new { LcID = DataBinder.Eval(c.DataItem,"LcID")});
});
});
if (ViewData["EditError"] != null)
{
grid.SetEditErrorText((string)ViewData["EditError"]);
}
}
@grid.Bind(Model).GetHtml()
------------代码结束--------------------
我所指的第二层GridView
文件名:RemoteClassPartial.cshtml
代码:
@using DevExpress.Web.Mvc
@using DevExpress.Web.Mvc.UI
@Html.DevExpress().GridView(
settings =>
{
settings.Name = "detailGrid_" + ViewData["LcID"];
settings.SettingsDetail.MasterGridName = "grid";
settings.CallbackRouteValues = new { Controller = "EditorialStaff", Action = "RemoteClassPartial", LcID = ViewData["LcID"] };
settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "EditorialStaff", Action = "AddRemoteClass"};
settings.Width = 800;
settings.KeyFieldName = "RcID";
settings.SettingsEditing.EditFormColumnCount = 2;
settings.CommandColumn.Visible = true;
settings.CommandColumn.ShowNewButton = true;
settings.CommandColumn.ShowNewButtonInHeader = true;
settings.SettingsBehavior.AllowFocusedRow = true;
settings.Columns.Add(column => {
column.FieldName = "RcName";
column.Caption = "名字";
column.ColumnType = MVCxGridViewColumnType.DateEdit;
DevExpress.Web.ASPxEditors.DateEditProperties deProperties = column.PropertiesEdit as DevExpress.Web.ASPxEditors.DateEditProperties;
deProperties.DisplayFormatString = "d";
deProperties.DisplayFormatInEditMode = true;
});
settings.Columns.Add(column => { column.FieldName = "RcRemark"; column.Caption = "备注"; });
}
).Bind(Model).GetHtml()
------------代码结束--------------------
问题重现: