2

我在这里关注了它,https://www.devexpress.com/Support/Center/Example/Details/E5116并在 ASP.NET MVC 中应用了给定的示例。以下是我的gridview设置示例部分代码:

settings.SettingsEditing.Mode = GridViewEditingMode.Batch;
settings.SettingsEditing.BatchEditSettings.EditMode = GridViewBatchEditMode.Row;
settings.CellEditorInitialize = (s, e) =>
{
    ASPxGridView grid = s as ASPxGridView;
    ASPxEdit editor = (ASPxEdit)e.Editor;
    if (e.Column.FieldName == "columnName1" || e.Column.FieldName == "columnName2")
    {
        e.Editor.ReadOnly = !grid.IsNewRowEditing;
    }
};

现在我不能在更新现有行数据的同时编辑两个单元格,这看起来很完美。

但我无法在使用新按钮创建新行时编辑两列。

注意:-它在以下情况下工作:

 settings.SettingsEditing.Mode = GridViewEditingMode.Inline;

但在编辑模式为Batch时不起作用。

4

1 回答 1

1

最后我在 DevExpress 支持的帮助下实现了这一点:

部分视图中的网格设置如下:

@Html.DevExpress().GridView(settings=> {
settings.Name = "gridViewPartial";
settings.CallbackRouteValues = new { Controller = "Home", Action = "gridViewPartial" };
settings.SettingsEditing.BatchUpdateRouteValues = new { Controller = "Admin", Action = "gridViewBatchUpdate" };

settings.KeyFieldName = "Id";

settings.SettingsEditing.Mode = GridViewEditingMode.Batch;
settings.SettingsEditing.BatchEditSettings.EditMode = GridViewBatchEditMode.Cell;


//to handle edit events on client side
**settings.ClientSideEvents.BatchEditStartEditing = "OnBatchStartEdit";**

settings.CommandColumn.Visible = true;
settings.CommandColumn.ShowDeleteButton = true;
settings.CommandColumn.ShowNewButtonInHeader = true;


settings.Columns.Add(column =>
{
    column.FieldName = "Id";
    column.Caption = "ID";
    column.ColumnType = MVCxGridViewColumnType.SpinEdit;

});
settings.Columns.Add(column =>
{
    column.FieldName = "Name";
    column.Caption = "Name";

});

}).Bind(Model).GetHtml()

我在其中引用部分视图的 Grid Normal 页面:

//script to handle edit event
function OnBatchStartEdit(s, e) {
    if ((e.focusedColumn.fieldName == "Id") && (e.visibleIndex > -1)) //cancel example
        e.cancel = true;;
}

如需进一步参考,请访问此处https://www.devexpress.com/Support/Center/Question/Details/T386483

于 2016-06-08T08:57:33.967 回答