Skip to main content
Solved

Custom popup close event


Hi everyone!

I have a custom popup and I need to clear view’s cache on the popup closing (after clicking on the close button). is it possible to track the window close event?

I also found the OnClosingPopup attribute, does anyone know in which cases it is used?

[PXButton(OnClosingPopup = PXSpecialButtonType.Cancel)]

 

Best answer by andriitkachenko

Turns out, Cancel doesn’t return a callback for some reason.

Ignore, Abort and No are working.

So, to make sure Close button sends callback to the backend, you need to add to your px:PXSmartPanel declaration in markup this:

CloseButtonDialogResult="Abort"

 If you decide to use No result, you can check it along with the Cancel result using:

if (dialogResult.IsNegative())
{
    return adapter.Get();
}

IsNegative checks dialog result against No and Cancel specifically - so if you use Abort or Ignore, the result of the check will be false.

If you want to use Abort or Ignore, you will have to check values against each possible result:

if(dialogResult == WebDialogResult.Abort || dialogResult == WebDialogResult.Cancel)
{
    return adapter.Get();
}

 

Regarding OnClosingPopup

OnClosingPopup, according to the XML documentation:

Gets or sets the special type of the button that will be triggerred on closing of an application webpage that is opened in popup mode. 

I’ve highlighted the “an application webpage” part because that’s the reason it doesn’t help you - it affects the screen with the action, but only when the action opens a new page in the popup - for example, by using PXPopupRedirectException or PXRedirectRequiredException exception. You open Smart Panel, which is a part of the same screen, so it operates differently.

View original
Did this topic help you find an answer to your question?

2 replies

andriitkachenko
Jr Varsity I
Forum|alt.badge.img+5

Hi @hannaborod.

The px:PXSmartPanel control has these properties to alter its Close button behaviour:

  • ShowCloseButton - Indicates whether the control is rendered with the Close button in the caption.
  • CommandName - The command that is executed after the panel is closed.
  • CloseButtonDialogResult - The dialog result for the Close button of the panel.

So, for example, with ShowCloseButton=”false” you can hide it altogether.

However, for your particular case, what you need is CloseButtonDialogResult="Cancel" (it accepts all values from PX.Data.WebDialogResult enum).

With this property set, you’ll receive a dialog result when the Close button is clicked.


andriitkachenko
Jr Varsity I
Forum|alt.badge.img+5

Turns out, Cancel doesn’t return a callback for some reason.

Ignore, Abort and No are working.

So, to make sure Close button sends callback to the backend, you need to add to your px:PXSmartPanel declaration in markup this:

CloseButtonDialogResult="Abort"

 If you decide to use No result, you can check it along with the Cancel result using:

if (dialogResult.IsNegative())
{
    return adapter.Get();
}

IsNegative checks dialog result against No and Cancel specifically - so if you use Abort or Ignore, the result of the check will be false.

If you want to use Abort or Ignore, you will have to check values against each possible result:

if(dialogResult == WebDialogResult.Abort || dialogResult == WebDialogResult.Cancel)
{
    return adapter.Get();
}

 

Regarding OnClosingPopup

OnClosingPopup, according to the XML documentation:

Gets or sets the special type of the button that will be triggerred on closing of an application webpage that is opened in popup mode. 

I’ve highlighted the “an application webpage” part because that’s the reason it doesn’t help you - it affects the screen with the action, but only when the action opens a new page in the popup - for example, by using PXPopupRedirectException or PXRedirectRequiredException exception. You open Smart Panel, which is a part of the same screen, so it operates differently.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings