TelerikWindow trigger function when using escape key

2 Answers 56 Views
Window
Martin Herløv
Top achievements
Rank 2
Bronze
Iron
Iron
Martin Herløv asked on 03 Feb 2022, 02:03 PM

I would like to call a function every time the window closes. No matter how the close was triggered.

<TelerikWindow Width="900px" Height="fit-content" Centered="true" Visible="@(Details.BaseData.Id > 0)" Modal="true" CloseOnOverlayClick="true">
    <WindowTitle>
        <strong>@Title</strong>
    </WindowTitle>
    <WindowActions>
        <WindowAction Name="Close" OnClick="OnFormClosed"/>
    </WindowActions>

2 Answers, 1 is accepted

Sort by
0
Blazorist
Top achievements
Rank 2
Bronze
Iron
Iron
answered on 03 Feb 2022, 03:37 PM
Hi Martin. 

Did you tried using VisibleChanged event?

<TelerikWindow Width="900px" Height="fit-content" Centered="true" Visible="@(Details.BaseData.Id > 0)" 
Modal="true" CloseOnOverlayClick="true" VisibleChanged="@VisibleChangedHandler">
<WindowTitle> <strong>@Title</strong> </WindowTitle> <WindowActions> <WindowAction Name="Close" OnClick="OnFormClosed"/> </WindowActions> </TelerikWindow>


@code{

public void VisibleChangedHandler(bool visible) 
{
IsVisible = visible; // set the window visibility
/* Do whatever you want */
}

Hope that will help.
Blazorist
Blazorist
Top achievements
Rank 2
Bronze
Iron
Iron
commented on 03 Feb 2022, 07:47 PM

I'm not sure if the VisibleChanged event is fired when the close button is pressed. If this happend, you could use OnFormClosed and VisibleChangedHandler simultaneously. 
0
Hristian Stefanov
Telerik team
answered on 08 Feb 2022, 09:10 AM

Hi all,

You are on the right path.

There are a couple of options here:

Please test to see which one of the above will suit your app requirements best.

Regards,
Hristian Stefanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Window
Asked by
Martin Herløv
Top achievements
Rank 2
Bronze
Iron
Iron
Answers by
Blazorist
Top achievements
Rank 2
Bronze
Iron
Iron
Hristian Stefanov
Telerik team
Share this question
or