Can't update row data by press enter

Hi Syncfusion Team,
I am using Grid and Dialog components. By default, the Grid component allows row data to be updated by pressing Enter after entering values. But when I use Grid with Dialog, this feature is disabled (when I press enter, nothing happens).

Sample: https://stackblitz.com/edit/react-qjcvar

I hope to use this feature in my project.

How can I config to use it?

Regards,
Hung Ton

3 Replies 1 reply marked as answer

PS Pavithra Subramaniyam Syncfusion Team April 11, 2022 01:04 PM UTC

Hi Hung Ton,


Thanks for contacting Syncfusion support.


You can achieve your requirement “Save Record with entering key while rendering Grid inside Dialog component” by calling the “endEdit” method inside the “keyPressed” event of Grid component. Please refer to the below code example, documentation, and sample link for more information.


In the below code example, we have called the “endEdit” method based on some conditions to check whether the current target is a valid input element and the currently opened popup is the Grid parent Dialog.


keyPressed(e) {

  if (e.code == 'Enter') {

    if (

      !parentsUntil(e.target, 'e-unboundcelldiv') && this.gridInstance.editSettings.mode !== 'Batch' &&

      (parentsUntil(e.target, 'e-gridcontent') || (this.gridInstance.frozenRows &&

          parentsUntil(e.target, 'e-headercontent'))) && document.getElementsByClassName('e-popup-open').length == 1 && document.getElementsByClassName('e-popup-open')[0].id =='GridParentDialog') {

      e.preventDefault();

      this.gridInstance.endEdit();

    }

  }

}

 


API        : https://ej2.syncfusion.com/react/documentation/api/grid/#keypressed

                https://ej2.syncfusion.com/react/documentation/api/grid/#endedit


Sample : https://stackblitz.com/edit/react-qjcvar-sq82tg


Please get back to us if you need further assistance on this.


Regards,

Pavithra S


Marked as answer

TT Ton That Hung April 12, 2022 02:35 AM UTC

Thanks for your support.



PS Pavithra Subramaniyam Syncfusion Team April 13, 2022 11:01 AM UTC

Hi Hung Ton,


Most welcome!


Please get back to us if you need further assistance on this.


Regards,

Pavithra S


Loader.
Up arrow icon