グリッドの編集時に他の変更可能な間に読み取り専用でなければならない機能を実現するmvcデベロッパーグリッドがあります。新しい列を追加するには、前に述べた読み取り専用列を含めてすべての列を変更可能にする必要があります。設定を使用します。グリッド全体ではなく特定の列にセルエディタを初期化します。
これは、グリッド
@{
var grid = Html.DevExpress().GridView(settings =>
{
settings.Name = "GridViewDuration";
settings.CallbackRouteValues = new { Controller = "DurationMaster", Action = "GridViewDurationPartial" };
settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "MyController", Action = "MyControllerAction1" };
settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "MyController", Action = "MyControllerAction2" };
settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "MyController", Action = "MyControllerAction3" };
settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
settings.SettingsBehavior.ConfirmDelete = true;
settings.CommandColumn.Visible = true;
settings.CommandColumn.ShowNewButton = true;
settings.CommandColumn.ShowDeleteButton = true;
settings.CommandColumn.ShowEditButton = true;
settings.KeyFieldName = "DurationId";
settings.SettingsPager.Visible = true;
settings.SettingsPager.PageSize = 20;
settings.Settings.ShowGroupPanel = true;
settings.Settings.ShowFilterRow = true;
settings.SettingsBehavior.AllowSelectByRowClick = false;
settings.Columns.Add(column =>
{
column.FieldName = "Column1";
column.ReadOnly = true;
column.Width = 20;
});
settings.Columns.Add(column =>
{
column.FieldName = "Column2";
column.Caption = "xyz";
column.ColumnType = MVCxGridViewColumnType.ComboBox;
column.Width = 250;
var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
comboBoxProperties.DataSource = PMC.Web.Controllers.DurationMasterController.getSelectList("0", "MyAction4");
comboBoxProperties.TextField = "Text";
comboBoxProperties.ValueField = "Value";
comboBoxProperties.ValueType = typeof(int);
comboBoxProperties.ValidationSettings.RequiredField.IsRequired = true;
});
settings.InitNewRow = (sender, e) =>
{
e.NewValues["ColumnId"] = 0;
};
settings.Columns.Add("ColumnName");
settings.Columns.Add("Description");
//settings.Columns.Add("DisplayName");
settings.Columns.Add(column =>
{
column.Caption = "FromDate";
column.FieldName = "FromDate";
column.ColumnType = MVCxGridViewColumnType.DateEdit;
column.ReadOnly = true;
var DateEditProperties = column.PropertiesEdit as DateEditProperties;
column.CellStyle.Wrap = DefaultBoolean.False;
});
settings.Columns.Add(column =>
{
column.Caption = "ToDate";
column.FieldName = "ToDate";
column.ColumnType = MVCxGridViewColumnType.DateEdit;
var DateEditProperties = column.PropertiesEdit as DateEditProperties;
column.CellStyle.Wrap = DefaultBoolean.False;
});
});
if (ViewData["EditError"] != null)
{
grid.SetEditErrorText((string)ViewData["EditError"]);
}
}
@grid.Bind(Model).GetHtml()
ための私のコードであり、これは私が唯一のfromDate
列を必要としながら、これは、読み取り専用で、すべてのグリッド列を設定します
settings.CellEditorInitialize += (s, e) =>
{
var abc = s as ASPxGridView;
e.Editor.ReadOnly = !abc.IsNewRowEditing;
};
を試みたものですbe readonly
助けていただければ幸いです。ありがとう。