# Select All Text in Grid Edit Cells on Tab Navigation or Click

## Description

When working with the [Kendo UI for Angular Grid](https://www.telerik.com/kendo-angular-ui/components/grid), it is often useful to automatically select the entire text in a cell when it receives focus, either through [tab navigation](https://www.telerik.com/kendo-angular-ui/components/grid/keyboard-navigation#controlling-the-focus) or a mouse click. This functionality improves the editing experience by allowing users to quickly replace the text without manually selecting it.

This article addresses the following common questions:

* How can I automatically select text in a Angular Data Grid cell on focus or click?
* How can I enhance the editing workflow in the Angular Grid using tab navigation and mouse interaction?
* How can I use custom edit templates to enable text selection in the Angular Grid?

## Environment

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

## Solution

To implement this functionality, use a custom edit template that includes the [Kendo UI for Angular TextBox](https://www.telerik.com/kendo-angular-ui/components/inputs/textbox) component. Handle the [`focus`](https://www.telerik.com/kendo-angular-ui/components/inputs/api/textboxcomponent#focus) event of the TextBox to select all text when the cell receives focus, whether through tab navigation or a mouse click.

### Steps to Implement

1. Use the [`kendoGridEditTemplate`](https://www.telerik.com/kendo-angular-ui/components/grid/api/edittemplatedirective) directive to define a custom edit template for the column. Inside the template, include the TextBox component and bind it to the form control.

   ```html
   <kendo-grid-column field="ProductName" title="Product Name">
     <ng-template kendoGridEditTemplate let-dataItem="dataItem" let-formGroup="formGroup">
       <kendo-textbox kendoGridFocusable [formControl]="formGroup.get('ProductName')" #textbox (focus)="onFocus(textbox)"></kendo-textbox>
     </ng-template>
   </kendo-grid-column>
   ```

   > Add the `kendoGridFocusable` directive to ensure that the TextBox can receive focus when navigating with the Tab key.

2. In the focus event handler, access the inner `<input>` element of the TextBox and call the <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select" target="_blank">`select()`</a> method to highlight all text.

   ```typescript
   onFocus(textbox: TextBoxComponent): void {
     textbox.input.nativeElement.select();
   }
   ```

This approach ensures that the text is selected when the cell receives focus, regardless of whether the focus is triggered by tab navigation or a mouse click.

## See Also

* [Custom Editors in the Data Grid](https://www.telerik.com/kendo-angular-ui/components/grid/editing/custom-editors)
* [Keyboard Navigation in the Data Grid](https://www.telerik.com/kendo-angular-ui/components/grid/keyboard-navigation)
* [Angular Grid API Reference](https://www.telerik.com/kendo-angular-ui/components/grid/api)
* [Kendo UI for Angular TextBox API Reference](https://www.telerik.com/kendo-angular-ui/components/inputs/api/textboxcomponent)
