Window prevent close triggered by content component

0 Answers 269 Views
Window
Vanessa
Top achievements
Rank 1
Vanessa asked on 07 Jun 2023, 12:01 PM

Hi,

https://www.telerik.com/kendo-angular-ui/components/dialogs/window/service/#toc-window-close-prevention

I want to open another component with the window service as described in the example above and want to trigger preventClose from inside the component by clicking on another button,

Like this:

https://stackblitz.com/edit/angular-vweamx

Inside the form.component in onConfirmAction window.close() is triggered but not preventClose. Is there any way to achieve this?

 

Goal would be to add an additional "cancel" button inside those dialogs, so preventClose should be triggered here just like the normal "x" of the dialog.

Georgi
Telerik team
commented on 12 Jun 2023, 10:29 AM

Hi Vanessa, 

Thank you very much for the details provided.

From what I understand from your question, you are currently utilizing the Kendo UI for Angular Window component opened via the WindowService and are looking for an approach that would allow you to prevent the closing of the Window from an element that is inside of it. Please, correct me if I misunderstood you. 

The default behavior of the preventClose() callback implies that it applies only to a click of the Close button on the title bar, pressing the Esc key, or calling the close() method.

In order to apply custom logic for preventing the closing of the Window, the developer could use the close method and apply custom conditions that will determine whether the component will be closed. To better illustrate this approach, I am sending a StackBlitz demo where the Window could not be closed until a value is not determined for the Age input:

https://stackblitz.com/edit/angular-vweamx-cixyyx?file=src%2Fapp%2Fform.component.ts

The logic could be further extended to fit the exact requirements for the implementation. 

In case the provided information does not help you achieve the desired behavior of the component, I would ask you to provide more detailed information about the exact requirements for the implementation so that I can work on a more case-specific solution. 

Let me know how it goes. 

Regards,
Georgi
Progress Telerik
Vanessa
Top achievements
Rank 1
commented on 13 Jun 2023, 06:22 AM

Hi,

since the default behavior of the preventClose() callback also includes "calling the close() method" I assumed this would also apply to calling the close event from the element inside the window. The reference to the WindowRef also seems to be correct.

We have some custom logic inside our preventClose() callback for several windows so adding the close condition inside the component would be twice the code. 

If this doesn not work as expected we will do it like this. Thanks for your time.

 

No answers yet. Maybe you can help?

Tags
Window
Asked by
Vanessa
Top achievements
Rank 1
Share this question
or