# Editing Overview

The [Telerik UI TreeList](https://demos.telerik.com/aspnet-mvc/treelist) provides a built-in editing functionality.

To implement the editing functionality of the TreeList:

1. [Set the model](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/treelist/editing/overview#setting-the-model)
2. [Configure the transport](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/treelist/editing/overview#configuring-the-transport)

## Setting the Model

All CRUD operations of the TreeList component require a model with `Id` and `ParentId` fields. Those models has to be configured in the DataSource of the TreeList. Based on the `ParentId` field, the TreeList distinguishes the root items. If the `ParentId` field is nullable, root items with be items whose `ParentId` field values are `null`. If the `ParentId` is not nullable, root items will be items which have a default value for their data type.

The following example demonstrates how to use the nullable model—items with ParentId `null` will be root items.

```Razor HtmlHelper
 	.DataSource(dataSource => dataSource
	...
	.Model(m => {
		m.Id(f => f.EmployeeId);
		m.ParentId(f => f.ReportsTo).Nullable(true);
```

```C# Model
    public int? ReportsTo { get; set; }
	public int EmployeeId { get; set; }
```

The following example demonstrates how to use the non-nullable model—items with ParentId `String.Empty` will be root items.

```Razor HtmlHelper
 	.DataSource(dataSource => dataSource
	...
	.Model(m => {
		m.Id(f => f.EmployeeId);
		m.ParentId(f => f.ReportsTo).Nullable(false);
```

```C# Model
    public string ReportsTo { get; set; }
	public string EmployeeId { get; set; }
```

## Configuring the Transport

Once the schema is configured, you need to configure the action methods in the DataSource for `"Update"`, `"Destroy"`, and `"Create"`. An important part of the CRUD operations is the response from the service, which needs to return the manipulated records, so that the TreeList can apply the changes to the DataSource accordingly. The new records also have to contain the newly assigned within the service `Id` value.

```Razor HtmlHelper
  .DataSource(dataSource => dataSource
      .Create(create => create.Action("Create", "EmployeeDirectory"))
      .Read(read => read.Action("All", "EmployeeDirectory"))
      .Update(update => update.Action("Update", "EmployeeDirectory"))
      .Destroy(delete => delete.Action("Destroy", "EmployeeDirectory"))
```

## Edit Modes

The TreeList supports the following edit modes:

* [Incell (batch) editing](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/treelist/editing/batch)
* [Inline editing](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/treelist/editing/inline)
* [Popup editing](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/treelist/editing/popup)
* [Editing by dragging and dropping of rows](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/treelist/editing/drag-drop-editing)

## Known Limitations

There are limitations when using editing along with other features of the component.

* If filtering is applied and `ServerOperation` is disabled in the DataSource configuration, adding new records is not allowed.

## See Also

* [Editing by the TreeList HtmlHelper for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/treelist/editing)
* [Incell Editing by the TreeList HtmlHelper for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/treelist/editing-incell)
* [Popup Editing by the TreeList HtmlHelper for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/treelist/editing-popup)
* [Editing by Dragging and Dropping in the TreeList HtmlHelper for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/treelist/dragdrop)
* [Server-Side API](https://www.telerik.com/aspnet-mvc/documentation/api/treelist)
