PDA

View Full Version : [OPEN] [#115] Event definition seem missing



feanor91
Apr 23, 2012, 9:17 AM
Hello

I try to use the BeforClose Event on panel but my code behind function is not close (event is not fired)



<DirectEvents>
<Show OnEvent="PanelChange"></Show>
<BeforeClose OnEvent="UpdatePanelPreference"></BeforeClose>
</DirectEvents>


If I use BeforeHide, it works (it was what I use in V1.x), but now, this event is called even when I change pane (witch is normal I think) but the problem, is that I didn't want to launch my function when panel is hidden but only when it is closed to save user's preferences to not see this panel next time they launch the application.

Edit: Close event is wall called, but could you please se what happened on BeforClose?

Daniil
Apr 23, 2012, 9:50 AM
Hi,

I was unable to reproduce with the example below - the BeforeClose DirectEvent is fired. Please provide your example.

Example


<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void BeforeClose(object sender, DirectEventArgs e)
{
X.Msg.Alert("BeforeClose", "BeforeClose").Show();
}
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:TabPanel runat="server">
<Items>
<ext:Panel runat="server" Title="Close me" Closable="true">
<DirectEvents>
<BeforeClose OnEvent="BeforeClose" />
</DirectEvents>
</ext:Panel>
</Items>
</ext:TabPanel>
</body>
</html>

feanor91
Apr 23, 2012, 10:10 AM
I try you example and it works.

I moved in in VB code and it works too.

I try to put exactly same code in my own code and it didn't work...Unexplainable...WTF in my code made it didn't work? And I think a big part of my problem came from the same thing.

feanor91
Apr 23, 2012, 11:50 AM
Hello

Here an example exerpt from my code that have the problem. I made a copy of my code removing all the grid part, with no interference made by some javascript code I could have write. Hope, that will be helpfull.



<%@ Page Language="vb"%>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>


<script runat="server">

Public Sub PanelChange(ByVal sender As Object, ByVal e As DirectEventArgs)
Ext.Net.X.Msg.Alert("Show Event", "Show").Show()
End Sub

Public Sub toto(ByVal sender As Object, ByVal e As Ext.Net.DirectEventArgs)
Ext.Net.X.Msg.Alert("BeforeClose Event", "BeforeClose").Show()
End Sub

Public Sub UpdatePanelPreference(ByVal sender As Object, e As DirectEventArgs)
Ext.Net.X.Msg.Alert("Close Event", "Close").Show()
End Sub
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ResMed Global KPIs</title>

<ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="ScriptFiles" />

<ext:XScript ID="XScript1" runat="server">
<script src="Main.js" type="text/javascript"></script>
</ext:XScript>

<link rel="stylesheet" type="text/css" href="Main.css" />

</head>

<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" RethrowAjaxExceptions="True">

</ext:ResourceManager>
<%-- Data stores--%>
<div>
</div>

<ext:Desktop
ID="MyDesktop"
runat="server">
<DesktopConfig Wallpaper="images/DesktopImages/RmdDesktop.jpg" WallpaperStretch="True" runat="server" Icons="start-button">
</DesktopConfig>

<Modules>

<%-- dataGrid window--%>
<ext:DesktopModule ModuleID="Data" AutoRun="True">
<Window>
<ext:Window
runat="server"
icon="Table"
X="1"
Y="1"
Hidden="True"
ExpandOnShow="True"
MinHeight="640"
MinWidth="480"
Title="Entity data"
Layout="FitLayout"
Width="1024"
Cls="x-grid-custom"
Height="600"
Collapsible="true"
TitleCollapse="true" Maximized="True">
<Content>
<ext:TabPanel ID="tabMain" runat="server" >
<Items>
<ext:Panel ID="tabOSA" runat="server" Title="OSA" Layout="FitLayout" Closable="true" CloseAction="Hide">
<DirectEvents>
<Show OnEvent="PanelChange"></Show>
<BeforeClose OnEvent="toto" />
<Close OnEvent="UpdatePanelPreference"></Close>
</DirectEvents>
</ext:Panel>
<ext:Panel ID="tabMASK" runat="server" Title="Masks" Layout="FitLayout" Closable="true" CloseAction="Hide">
<DirectEvents>
<Show OnEvent="PanelChange"></Show>
<BeforeClose OnEvent="toto" />
<Close OnEvent="UpdatePanelPreference"></Close>
</DirectEvents>
</ext:Panel>
<ext:Panel ID="tabVEN" runat="server" Title="Ventilation" Layout="FitLayout" Closable="true" CloseAction="Hide">
<DirectEvents>
<Show OnEvent="PanelChange"></Show>
<BeforeClose OnEvent="toto" />
<Close OnEvent="UpdatePanelPreference"></Close>
</DirectEvents>
</ext:Panel>
<ext:Panel ID="tabTPP" runat="server" Title="3rd Party products" Layout="FitLayout" Closable="true" CloseAction="Hide">
<DirectEvents>
<Show OnEvent="PanelChange"></Show>
<BeforeClose OnEvent="toto" />
<Close OnEvent="UpdatePanelPreference"></Close>
</DirectEvents>
</ext:Panel>
<ext:Panel ID="tabATS" runat="server" Title="Activity Type split" Layout="FitLayout" Closable="true" CloseAction="Hide">
<DirectEvents>
<Show OnEvent="PanelChange"></Show>
<BeforeClose OnEvent="toto" />
<Close OnEvent="UpdatePanelPreference"></Close>
</DirectEvents>
</ext:Panel>
<ext:Panel ID="tabTRS" runat="server" Title="Type of repair split" Layout="FitLayout" Closable="true" CloseAction="Hide">
<DirectEvents>
<Show OnEvent="PanelChange"></Show>
<BeforeClose OnEvent="toto" />
<Close OnEvent="UpdatePanelPreference"></Close>
</DirectEvents>
</ext:Panel>
<ext:Panel ID="tabPS" runat="server" Title="Product split" Layout="FitLayout" Closable="true" CloseAction="Hide">
<DirectEvents>
<Show OnEvent="PanelChange"></Show>
<BeforeClose OnEvent="toto" />
<Close OnEvent="UpdatePanelPreference"></Close>
</DirectEvents>
</ext:Panel>
<ext:Panel ID="tabFCC" runat="server" Title=" For Call centers" Layout="FitLayout" Closable="true" CloseAction="Hide">
<DirectEvents>
<Show OnEvent="PanelChange"></Show>
<BeforeClose OnEvent="toto" />
<Close OnEvent="UpdatePanelPreference"></Close>
</DirectEvents>
</ext:Panel>
<ext:Panel ID="tabLO_OM" runat="server" Title="Order metrics" Layout="FitLayout" Closable="true" CloseAction="Hide">
<DirectEvents>
<Show OnEvent="PanelChange"></Show>
<BeforeClose OnEvent="toto" />
<Close OnEvent="UpdatePanelPreference"></Close>
</DirectEvents>
</ext:Panel>
<ext:Panel ID="tabLO_AVA" runat="server" Title="Availability" Layout="FitLayout" Closable="true" CloseAction="Hide">
<DirectEvents>
<Show OnEvent="PanelChange"></Show>
<BeforeClose OnEvent="toto" />
<Close OnEvent="UpdatePanelPreference"></Close>
</DirectEvents>
</ext:Panel>
<ext:Panel ID="tabFI" runat="server" Title="Financials" Layout="FitLayout" Closable="true" CloseAction="Hide">
<DirectEvents>
<Show OnEvent="PanelChange"></Show>
<BeforeClose OnEvent="toto" />
<Close OnEvent="UpdatePanelPreference"></Close>
</DirectEvents>
</ext:Panel>
</Items>
</ext:TabPanel>
</Content>
<%--
<TopBar>
<ext:Toolbar ID="tbEntities" runat="server" >
<Content>
<ext:Panel ID="Panel1" runat="server" Layout="ColumnLayout" BaseCls="x-plain" Width="800px" Height="25px">
<LayoutConfig>
<ext:HBoxLayoutConfig Align="Middle" />
</LayoutConfig>
<Items>
<ext:Button ID="btnRestorePanel" runat="server" Text="Restore panel">
<DirectEvents>
<Click OnEvent="btnRestorePanel_Click"></Click>
</DirectEvents>
</ext:Button>
<ext:Button ID="btnShowEntities" runat="server" Text="Show all entities">
<DirectEvents>
<Click OnEvent="btnShowEntities_Click"></Click>
</DirectEvents>
</ext:Button>
<ext:Panel ID="Panel2" runat="server" BaseCls="x-plain" Flex="1" />
<ext:Checkbox ID="chkExpandDefault" runat="server" FieldLabel="Expand my entity">
<DirectEvents>
<Check OnEvent="UpdateExpandDefault"></Check>
</DirectEvents>
</ext:Checkbox>
<ext:Panel ID="Panel9" runat="server" BaseCls="x-plain" Flex="3" />
<ext:Label ID="Label1" runat="server" Text="Red : estimated value" Cls="x-red"></ext:Label>
<ext:Label ID="Label2" runat="server" Text="Blue : measured value" Cls="x-blue"></ext:Label>
</Items>
</ext:Panel>
</Content>
</ext:Toolbar>
</TopBar>
--%>
</ext:Window>
</Window>
</ext:DesktopModule>


</Modules>

</ext:Desktop>

</form>
</body>

</html>



Edit: change code to have shorter one

Daniil
Apr 23, 2012, 2:26 PM
I think the two - BeforeClose and Close - should not be fired with CloseAction="Hide".

If you use

CloseAction="Hide"
then we can suggest to use the TabPanel BeforeTabHide and TabClose events for now.

We will consider to make it more clear in the future.

feanor91
Apr 23, 2012, 2:29 PM
I think the two - BeforeClose and Close - should not be fired with CloseAction="Hide".

If you use

CloseAction="Hide"
then we can suggest to use the TabPanel BeforeTabHide and TabClose events for now.

We will consider to make it more clear in the future.

OK, I will test that and keep you in touch. BTW, for now I use


CloseAction="Hide"

and the Close event is well called.

Daniil
Jan 04, 2013, 12:23 PM
We will consider to make it more clear in the future.

Created an Issue, see:
https://github.com/extnet/Ext.NET/issues/115

How it should be:



If a tab has CloseAction="Destroy" (by default), then:

a tab should fire BeforeClose, Close
a TabPanel - BeforeTabClose, TabClose.


If a tab has CloseAction="Hide", then

a tab should fire BeforeHide, Hide, BeforeClose, Close
a TabPanel - BeforeTabClose, TabClose


Also it needs to remove the TabPanel's BeforeTabHide because the BeforeTabClose one is enough.