devExpress 使用 GridView 嵌套 GridView 数据编辑

发布于 2022-08-31 09:14:25 字数 4039 浏览 33 评论 0

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()
------------代码结束--------------------

问题重现:
问题重现

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文