How to automatically focus the input after clicking for in-cell Grid Editing

0 Answers 40 Views
Grid
n/a
Top achievements
Rank 1
Iron
n/a asked on 16 Jan 2025, 06:21 AM

How to automatically focus the input after clicking for in-cell Grid Editing like jquery

Petar
Telerik team
commented on 20 Jan 2025, 12:27 PM

Hello, Qiushen Jiang.

Here is a StackBlitz example demonstrating how to implement the targeted functionality.

To achieve the demonstrated behavior, we use the following, marked in yellow, code:

cellClick: function (e) {
  if (e.dataItem.inEdit && e.field === this.editField) {
    return;
  }

  this.exitEdit(e.dataItem, true);
  this.editField = e.field;
  e.dataItem.inEdit = e.field;
  this.$nextTick(() => {
    const input = document.querySelector(
      `input[value="${e.dataItem[e.field]}"]`
    );
    input && input.focus();
  });
}

Please let me know if you need furhter assistance with the implementation of your scenario. 

No answers yet. Maybe you can help?

Tags
Grid
Asked by
n/a
Top achievements
Rank 1
Iron
Share this question
or