TreeList editor focus

1 Answer 137 Views
TreeList
Alex
Top achievements
Rank 1
Iron
Alex asked on 10 Mar 2023, 05:16 PM

Hello,

I am using a TreeList with a custom cell editor defined in a kendoTreeListEditTemplate. In my code I'm switching between different editors for different scenarios, but here's a basic example with just one:

        <ng-template kendoTreeListEditTemplate
             let-column="column"
             let-formGroup="formGroup">
             <kendo-numerictextbox [formControl]="formGroup.get(column.field)" [spinners]="false"></kendo-numerictextbox>
        </ng-template>

I am using the TreeListComponent.editCell function to edit the cell. Right now, the text box is not being focused, so the user has to click an additional time in order to start entering data.
How would I get the TreeList to automatically focus the editor when editCell is called?

1 Answer, 1 is accepted

Sort by
0
Accepted
Alex
Top achievements
Rank 1
Iron
answered on 10 Mar 2023, 05:56 PM
I resolved this using a timeout after calling editCell
 setTimeout(() => {
      const input: HTMLInputElement = document.querySelector(`.k-grid-edit-cell input`);
      input.focus();
}

Tags
TreeList
Asked by
Alex
Top achievements
Rank 1
Iron
Answers by
Alex
Top achievements
Rank 1
Iron
Share this question
or