Skip to main content

GridViewSettings.CellEditorInitialize Property

Enables initializing the cell editors displayed within the grid edit cells.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v24.2.dll

Declaration

public ASPxGridViewEditorEventHandler CellEditorInitialize { get; set; }

Property Value

Type Description
ASPxGridViewEditorEventHandler

A ASPxGridViewEditorEventHandler delegate method allowing you to implement custom processing.

Remarks

The CellEditorInitialize event is raised when the GridView is switched to edit mode and enables you to initialize cell editors.

Note

  • Since the CellEditorInitialize event works correctly only when a request is sent to the server to initialize an editor, this event will not be raised after you start editing a new row in Batch edit mode because in this mode, requests are not sent to the server when an editor is activated.
  • The CellEditorInitialize event affects only the edit mode settings (when editors are visible).
  • The CellEditorInitialize event isn’t raised for edit cells that contain custom editors defined using templates.
  • The CellEditorInitialize event fires only for built-in column editors.

Examples

  • The following example illustrates how to use the CellEditorInitialize event to automatically focus the required column’s editor using the editor’s ASPxWebControl.Focus method (the e.Editor event argument).

    settings.CellEditorInitialize = (s, e) => {
        if (e.Column.FieldName == "TimeFrom")
        {
            e.Editor.Focus();
        }
    };
    
  • This example demonstrates how to prevent an end-user from changing the unit price. To do this, the CellEditorInitialize event is handled. If the processed edit cell corresponds to a column bound to the ‘UnitPrice’ data field, its editor’s ReadOnly property is set to true.

    settings.CellEditorInitialize = (s, e) => {
        MVCxGridView gridViewControl = (MVCxGridView)sender;
        if (gridViewControl.IsNewRowEditing) return;
        if (e.Column.FieldName == "UnitPrice")
            e.Editor.ReadOnly = true;
    }
    
See Also