Configuration editing

    Contains options that specify how grid content can be changed.

    Type: Object

    dxDataGrid supports editing, insertion and the removing of grid values. The availability of performing a certain operation is specified by the editEnabled, insertEnabled and removeEnabled options.

    Editing in dxDataGrid can be performed in two different modes: row and batch. In the row mode, all changes made in grid rows are reflected in the data source immediately after editing completes. In the batch mode, changes are buffered before being transmitted to the data source. The user sends them manually once he or she finishes editing.

    See Also
    • For more information about editing settings you can configure, including both edit modes, refer to the Editing in UI topic.
    • To discover how to manage the editing process from code, see the Editing in Code topic.

    NOTE: Before allowing a user to edit, insert and remove, make sure your data source supports all these actions.

    View Demo

    Show Example:
    jQuery

    In this example, you can perform all kinds of data modifications available in the dxDataGrid widget: row editing, insertion and removal. These operations are conducted in the batch edit mode. All these settings are specified using the fields of the editing configuration object.

    <div id="gridContainer" style="height:390px; max-width:800px; margin: 0 auto"></div>
    
    $(function () {
        $("#gridContainer").dxDataGrid({
            dataSource: books,
            columns: [
                'author',
                { dataField: 'title', width: 210 },
                'year', 'genre', 'format'
            ],
            paging: { pageSize: 7 },
            editing: {
                editMode: 'batch',
                editEnabled: true,
                insertEnabled: true,
                removeEnabled: true
            }
        });
    });
    

    editEnabled

    Specifies whether or not grid records can be edited at runtime.

    Type: Boolean
    Default Value: false

    Show Example:
    jQuery

    In this example, you can change the value of the editEnabled option at runtime using the check box below. If this option is true, the grid is supplied with an additional column that contains "Edit" buttons enabling you to edit grid records. Otherwise, this column is hidden, and the grid records cannot be edited.

    <div id="gridContainer" style="height:380px; max-width:800px; margin: 0 auto"></div>
    <div id="checkboxContainer" style="height:20px;margin:5px auto;text-align:center">
        <input type="checkbox" id="enableEditingCheckbox" checked> Enable Row Editing
    </div>
    $(function () {
        $("#gridContainer").dxDataGrid({
            dataSource: books,
            columns: [
                'author',
                { dataField: 'title', width: 210 },
                'year', 'genre', 'format'
            ],
            paging: { pageSize: 8 },
            editing: { editEnabled: true }
        });
    
        $('#enableEditingCheckbox').change(function () {
            var dataGrid = $('#gridContainer').dxDataGrid('instance');
            dataGrid.option({
                editing: { editEnabled: this.checked }
            });
        });
    });

    editMode

    Specifies how grid values can be edited manually.

    Type: String
    Default Value: "row"
    Accepted Values: "row" | "batch" | "cell"

    Editing grid values requires the editEnabled option to be set to true.

    For a comprehensive overview of available edit modes, refer to the Row Mode, Batch Mode and Cell Mode articles.

    View Demo

    Show Example:
    jQuery

    In this example, you can try all edit modes presented in the dxDataGrid widget. To change the current edit mode, choose the required item from the drop-down menu under the grid.

    <div id="gridContainer" style="height: 380px; max-width: 800px; margin: 0 auto"></div>
    <div style="height:25px;text-align:center">
        Choose an edit mode:
        <select id="editModeSelector">
            <option value="row">row</option>
            <option value="batch">batch</option>
            <option value="cell">cell</option>
        </select>
    </div>
    $(function () {
        $("#gridContainer").dxDataGrid({
            dataSource: books,
            columns: [
                'author',
                { dataField: 'title', width: 210 },
                'year', 'genre', 'format'
            ],
            paging: { pageSize: 7 },
            editing: {
                editMode: 'row',
                editEnabled: true,
                insertEnabled: true,
                removeEnabled: true
            }
        });
    
        $('#editModeSelector').change(function () {
            var dataGrid = $('#gridContainer').dxDataGrid('instance');
            dataGrid.option({
                editing: { editMode: this.value }
            });
        });
    });
    

    insertEnabled

    Specifies whether or not new records can be inserted into a grid.

    Type: Boolean
    Default Value: false

    Show Example:
    jQuery

    In this example, you can change the value of the insertEnabled option at runtime using the check box below. If this option is true, the grid is supplied with a button that inserts a new record into the grid. Otherwise, this button is hidden, and you cannot insert records into the grid.

    <div id="gridContainer" style="height:380px; max-width:800px; margin: 0 auto"></div>
    <div id="checkboxContainer" style="height:20px;margin:5px auto;text-align:center">
        <input type="checkbox" id="enableInsertionCheckbox" checked> Enable Row Insertion
    </div>
    $(function () {
        $("#gridContainer").dxDataGrid({
            dataSource: books,
            columns: [
                'author',
                { dataField: 'title', width: 210 },
                'year', 'genre', 'format'
            ],
            paging: { pageSize: 8 },
            editing: {
                insertEnabled: true,
                removeEnabled: true
            }
        });
    
        $('#enableInsertionCheckbox').change(function () {
            var dataGrid = $('#gridContainer').dxDataGrid('instance');
            dataGrid.option({
                editing: { insertEnabled: this.checked }
            });
            dataGrid.repaint();
        });
    });

    removeEnabled

    Specifies whether or not records can be deleted from a grid.

    Type: Boolean
    Default Value: false

    Show Example:
    jQuery

    In this example, you can change the value of the removeEnabled option at runtime using the check box below. If this option is true, the grid is supplied with an additional column that contains "Delete" buttons enabling you to delete grid records. Otherwise, this column is hidden, and the grid records cannot be deleted.

    <div id="gridContainer" style="height:380px; max-width:800px; margin: 0 auto"></div>
    <div id="checkboxContainer" style="height:20px;margin:5px auto;text-align:center">
        <input type="checkbox" id="enableRemovalCheckbox" checked> Enable Row Removal
    </div>
    $(function () {
        $("#gridContainer").dxDataGrid({
            dataSource: books,
            columns: [
                'author',
                { dataField: 'title', width: 210 },
                'year', 'genre', 'format'
            ],
            paging: { pageSize: 8 },
            editing: { removeEnabled: true }
        });
    
        $('#enableRemovalCheckbox').change(function () {
            var dataGrid = $('#gridContainer').dxDataGrid('instance');
            dataGrid.option({
                editing: { removeEnabled: this.checked }
            });
        });
    });

    texts

    Contains options that specify texts for editing-related grid controls.

    Type: Object

    For detailed information on editing-related grid controls, see the Data Modification Controls topic.

    Show Example:
    jQuery

    In this example, several options of the editing | texts configuration object are changed.

    <div id="gridContainer" style="height:390px; max-width:800px; margin: 0 auto"></div>
    
    $(function () {
        $("#gridContainer").dxDataGrid({
            dataSource: books,
            columns: [
                'author',
                { dataField: 'title', width: 210 },
                'year', 'genre', 'format'
            ],
            paging: { pageSize: 8 },
            editing: {
                editMode: 'row',
                editEnabled: true,
                removeEnabled: true,
                texts: {
                    deleteRow: 'Remove',
                    saveRowChanges: 'OK',
                    confirmDeleteTitle: 'Confirm Row Deletion'
                }
            }
        });
    });