# Editing Basics

You can create, update, and delete the data records of the TreeList.

## Getting Started

1. Set the [`editField`](https://www.telerik.com/kendo-react-ui/components/treelist/api/treelistprops#editfield) property of the TreeList—`editField` will indicate the editable data items and is part of the temporary data items that are used during editing. For the data items in the edit mode, set the edit state in their `editField`. In the following example, the id of the edited item is stored in the application state.

   ```jsx
       <TreeList
           editField="inEdit"
   ```

   ```jsx
       dataItem.inEdit = true;
   ```

2. Create a new data tree which has the edit state of each data item by using the [`mapTree`](https://www.telerik.com/kendo-react-ui/components/treelist/api/maptree) function.

   ```jsx
       <TreeList
           editField="inEdit"
           data={
               mapTree(data, subItemsField, item =>
                   extendDataItem(item, subItemsField, {
                       inEdit: item.id === this.state.editId
                   })
               )
           }
   ```

3. Set the [`editCell`](https://www.telerik.com/kendo-react-ui/components/treelist/api/treelistcolumnprops#editcell) property per column. The built-in editor components are the [`TreeListTextEditor`](https://www.telerik.com/kendo-react-ui/components/treelist/api/treelisttexteditor), [`TreeListNumericEditor`](https://www.telerik.com/kendo-react-ui/components/treelist/api/treelistnumericeditor), [`TreeListDateEditor`](https://www.telerik.com/kendo-react-ui/components/treelist/api/treelistdateeditor), and [`TreeListBooleanEditor`](https://www.telerik.com/kendo-react-ui/components/treelist/api/treelistbooleaneditor). The usage of each component for each column depends on the type of the edited data.

   ```jsx
       <TreeList
           columns={[
               { field: 'name', editCell: TreeListTextEditor, ... },
               { field: 'position', editCell: TreeListTextEditor, ... },
               { field: 'hireDate', editCell: TreeListDateEditor, ... },
               { field: 'timeInPosition', editCell: TreeListNumericEditor, ... },
               { field: 'fullTime', editCell: TreeListBooleanEditor, ... }
           ]}
   ```

4. Define a function for the [`onItemChange`](https://www.telerik.com/kendo-react-ui/components/treelist/api/treelistprops#onitemchange) event which will handle the data changes during editing. Inside the event, all relevant data, such as the edited data item, the newly entered value, or the edited field will be available as [`onItemChange`](https://www.telerik.com/kendo-react-ui/components/treelist/api/treelistitemchangeevent) parameters.

   ```jsx
        <TreeList onItemChange={this.onItemChange}>
   ```

   ```jsx
       onItemChange = (event) => {
           this.setState({
               data: mapTree(
                   this.state.data,
                   subItemsField,
                   item => item.id === event.dataItem.id ?
                       extendDataItem(item, subItemsField, { [event.field]: event.value }) : item
               )
           });
       }
   ```

The following example demonstrates how to set the TreeList in edit mode.

[Demo Source](https://demos.telerik.com/kendo-react-ui/treelist/editing-row-click/func/source.txt)

## Edit Modes

* [Inline edit mode](https://www.telerik.com/kendo-react-ui/components/treelist/editing/editing-inline)
* [In-cell edit mode](https://www.telerik.com/kendo-react-ui/components/treelist/editing/editing-in-cell)
* [Editing with external popup form](https://www.telerik.com/kendo-react-ui/components/treelist/editing/editing-external-form)

## Suggested Links

* [API Reference of the TreeList](https://www.telerik.com/kendo-react-ui/components/treelist/api/treelistprops)
* [API Index of the TreeList](https://www.telerik.com/kendo-react-ui/components/treelist/api)
