Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
Igx Spreadsheet - Prevent or Cancel User Prompt or Ability to save changes when focus is lost
posted

We are using the Igx Spreadsheet in an angular component. If a user enters data that triggers a validation error (i.e. not a valid formula like =()), then the alert box shown below appears.  The problem that we are having is that we have code wired up to the (focusout) event of the component to call ExitEditModeAndUpdateActiveCell. 

it's this code here: this.spreadsheet.executeAction(SpreadsheetAction.ExitEditModeAndUpdateActiveCell)

this is because our Save button is located outside the component and this catches the situation where someone types something (never leaves the cell) and then clicks out of the component to Save. Apparently (and unfortunately), the Igx Spreadsheet does not ExitEditModeAndUpdate if focus is lost outside of the component.  

Since this code occurs in the focusout event, when the user clicks OK on the alert box, it creates an infinite loop where it calls focusout again. Is there a way to prevent or hide this alert box from being displayed? I see this event here userPromptDisplaying but I do not see how to customize this alert box or prevent it. Or alternatively, what is the suggestion for handling scenario of ExitEditModeAndUpdate  when the focus is gone from the component in order to have the user's data saved?

  • 34430
    Offline posted

    Hello Krista,

    I have been investigating into the behavior you are seeing, and in order to prevent the alert box from being displayed, you can utilize the userPromptDisplaying event and set the event arguments’ displayMessage property to false. This should prevent the infinite loop you are seeing from the focusout event. An alternative in this case could also be to set a flag in the userPromptDisplaying event that you can check in the focusout event so that you can prevent the infinite loop.

    Another alternative could be to instead call the ExitEditModeAndUpdateActiveCell in your save button prior to doing your save operation rather than doing this in focusout. This too, should avoid the infinite loop you are seeing in the case of the user prompt displaying and firing focusout again.

    Please let me know if you have any other questions or concerns on this matter.