We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Proper way to commit a Template-driven Forms based editor?

Thread ID:

Created:

Updated:

Platform:

Replies:

149697 Dec 5,2019 07:07 PM UTC Dec 6,2019 10:50 AM UTC Angular - EJ 2 1
loading
Tags: Grid
pcafstockf
Asked On December 5, 2019 07:07 PM UTC

Hi,

I've created a sample based loosely on the documentation for Template-driven Forms.

The editor works as expected if you click to edit, make changes, then hit the Enter key to commit your changes.
However, I want to also commit the changes if the user clicks outside the grid (grid loses focus).
I added an input element at the top of the sample page that can be clicked to steal focus.

Basically I'm looking for the 'actionOnBlur' property of the InPlaceEditor component, but for a Template based Grid editor.


Also, if there is a more preferred way to write the html for the ng-template editor, I'd like some feedback on that as well.

Thanks



Pavithra Subramaniyam [Syncfusion]
Replied On December 6, 2019 10:50 AM UTC

Hi Earl, 
 
You can achieve your requirement – “Save edit changes on focusing the input element rendered outside the grid” by binding focus event to this element and calling the grid’s endEdit method if it is in edit state. This is demonstrated in below code snippet, 
 
<input type='text' size='25' name='shiftFocus' (focus)='onFocus()' placeholder='click-here-to-steal-focus' /> 
 
public onFocus() { 
    // Check is the grid is in edit state 
    if (this.grid.isEdit) { 
        // Saves the record 
        this.grid.endEdit(); 
    } 
} 
 
 
For your reference we have modified the sample you provided based on this. You can find it below, 
 
 
Please get back to us if you have any further queries. 
 
Regards, 
Pavithra S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon