# Angular TreeList Custom Editing Service

The [Angular TreeList](https://www.telerik.com/kendo-angular-ui-develop/components/treelist) provides [built-in editing directives](https://www.telerik.com/kendo-angular-ui-develop/components/treelist/editing#quick-setup) that handle data operations automatically. However, for complex scenarios where you need more control over the CRUD operations, data validation, or integration with external APIs, you can implement a custom editing service.

Each editing directive exposes an [`editService`](https://www.telerik.com/kendo-angular-ui-develop/components/treelist/api/reactiveeditingdirective#editservice) property that allows you to replace the default data handling with your own custom logic. The custom service manages the create, read, update, and delete operations and must implement the [`EditService`](https://www.telerik.com/kendo-angular-ui-develop/components/treelist/api/editservice) interface.

> If the TreeList is not bound to a plain array, you must specify an `EditService`.

The following example demonstrates how to implement a custom editing service.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/treelist/editing/editing-directives/custom-service/source.txt)

## Setup

To implement a custom editing service for the TreeList:

1. Create a service that implements the `EditService` interface to manage editing operations and track data changes.

   ```typescript
   @Injectable()
   export class MyEditService implements EditService {
       // Implement CRUD operations for your data source.
   }
   ```

2. Implement the required CRUD methods of the `EditService` interface. The TreeList will call these methods when users perform the corresponding editing operations.

   ```typescript
   public create(item: any): void {
       // Add the item to your data source.
   }

   public update(item: any): void {
       // Update the item in your data source.
   }

   public remove(item: any): void {
       // Remove the item from your data source.
   }

   public assignValues(target: unknown, source: unknown): void {
       Object.assign(target, source);
   }
   ```

   > The `assignValues` method is used by the TreeList to update item values during editing operations.

3. Configure the TreeList to use your custom service by setting the `editService` property and providing the service in your component.

   ```typescript
   @Component({
       providers: [MyEditService],
       template: `
           <kendo-treelist
               [kendoTreeListInCellEditing]="createFormGroup"
               [editService]="editService"
               ...
           >
           </kendo-treelist>
       `
   })
   export class AppComponent {
       constructor(public editService: MyEditService) {}
   }
   ```

## See Also

* [Angular TreeList Editing Basics](https://www.telerik.com/kendo-angular-ui-develop/components/treelist/editing)
* [EditService](https://www.telerik.com/kendo-angular-ui-develop/components/treelist/api/editservice)
* [ReactiveEditingDirective](https://www.telerik.com/kendo-angular-ui-develop/components/treelist/api/reactiveeditingdirective)
* [InCellEditingDirective](https://www.telerik.com/kendo-angular-ui-develop/components/treelist/api/incelleditingdirective)
* [API Reference of the TreeListComponent](https://www.telerik.com/kendo-angular-ui-develop/components/treelist/api/treelistcomponent)
* [API Index of the TreeList](https://www.telerik.com/kendo-angular-ui-develop/components/treelist/api)
