我在这里关注它,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;
但在编辑模式批次时无法正常工作。
答案 0 :(得分:0)
最后,我在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()
网格正常页面,我在其中引用局部视图:
//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