# Extending In-Cell Editing Directive to Prevent Editing Specific Cells

## Environment

<table>
	<tbody>
		<tr>
			<td>Product</td>
			<td>Progress® Kendo UI® Data Grid for Angular</td>
		</tr>
	</tbody>
</table>

## Description

I want to extend the [`kendoGridInCellEditing`](https://www.telerik.com/kendo-angular-ui-develop/components/grid/api/incelleditingdirective) directive to prevent editing on specific cells based on conditions from the [`cellClick`](https://www.telerik.com/kendo-angular-ui-develop/components/grid/api/cellclickevent) event arguments. For example, I want to prevent editing in the first column of the Grid. The default behavior of the `kendoGridInCellEditing` directive is to allow editing for all cells, and it uses the [`k-grid-ignore-click`](https://www.telerik.com/kendo-angular-ui-develop/components/grid/editing/in-cell-editing#disabling-the-click-handler-for-specific-elements) class to disable the click handler for specific elements.

The goal is to allow more flexible editing behavior without relying on the `k-grid-ignore-click` class.

This knowledge base article also answers the following questions:

* How to disable editing for specific cells in Kendo UI for Angular Grid?
* How to extend the Kendo UI for Angular Grid In-Cell Editing directive?
* How to conditionally allow editing in Kendo UI for Angular Grid cells?

## Solution

To achieve this, extend the `kendoGridInCellEditing` directive and manually define the logic to prevent editing for specific cells based on your application requirements.

1. Create a custom directive that extends the `InCellEditingDirective`.

   ```ts
   import { Directive, Input } from '@angular/core';
   import { InCellEditingDirective, CellClickEvent } from '@progress/kendo-angular-grid';
   import { CreateFormGroup } from '@progress/kendo-angular-grid';

   @Directive({
     selector: '[customGridInCellEditing]',
     standalone: true,
   })
   export class CustomInCellEditingDirective extends InCellEditingDirective {
   }
   ```

2. Override the `cellClickHandler` method to define conditional logic for editable cells.

   ```ts
   protected override cellClickHandler(args: CellClickEvent): void {
     // Prevent editing for the first column
     // You can customize this condition based on your requirements
     if (args.columnIndex === 0) {
       return;
     }

     // Invoke the default behavior for other cells
     super.cellClickHandler(args);
   }
   ```

3. Create a form group for the cell editing and bind the custom directive to it.

   ```html
   <kendo-grid
     [customGridInCellEditing]="createFormGroup"
     ...>
   </kendo-grid>
   ```

The following example demonstrates how to extend the `kendoGridInCellEditing` directive to prevent editing in the first column of the Grid.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/knowledge-base/grid-extend-incellediting-directive-to-prevent-editing/source.txt)

## See Also

* [Kendo UI for Angular Grid Editing Overview](https://www.telerik.com/kendo-angular-ui-develop/components/grid/editing/basics)
* [Kendo UI for Angular Grid In-Cell Editing](https://www.telerik.com/kendo-angular-ui-develop/components/grid/editing/in-cell-editing)
