[CLOSED] After hiding popup window

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] After hiding popup window

    After I hide/close a popup window is the an easy way to notify the associated parent to perform an action?

    After hiding the popup window I want to tell the grid to refresh itself because I have deleted some rows. I have an associated thread that is asking if I am showing the popup properly.

    I the code behind for the popup I execute the following to hide the popup:

      X.AddScript("parentAutoLoadControl.hide()");
    Last edited by Daniil; May 03, 2012 at 3:11 PM. Reason: [CLOSED]
  2. #2
    Hi.. i use the new fantastic component MessageBus to notify action to other component and work great...It could be for you..

    This is a small sample from send e receive event from the messagebus
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Window ID="Window1" runat="server" Collapsible="true" Height="185" Icon="Application"
            Title="Window1" Width="350" X="10" Y="10">
            <Items>
              <ext:TextField ID="TextField2" runat="server" Text="Test">
                </ext:TextField>
            <ext:Button ID="Button1" runat="server" Text="Send value of field to window2">
                                <Listeners>
                                   <%--   //Send to messagebus an event with name refresh--%>
                                    <Click Handler="Ext.net.Bus.publish('refresh', #{TextField2}.getValue());" />
                                </Listeners>
                            </ext:Button>
            </Items>
             
        </ext:Window>
        <ext:Window ID="Window2" runat="server" Collapsible="true" Height="185" Icon="Application"
            Title="Window2" Width="350" Y="220" X="10">
            <Items>
                <ext:TextField ID="TextField1" runat="server">
                </ext:TextField>
            </Items>
         <%--   //It listens from the messagebus and takes all the events named refresh--%>
            <MessageBusListeners>
                        <ext:MessageBusListener 
                            Name="refresh" 
                            Handler="#{TextField1}.setValue(data);" 
                            />
                    </MessageBusListeners>
        </ext:Window>
    
        </form>
    </body>
    </html>
    Thanks
    Aurelio
  3. #3
    Hi all,

    Yes, I think Aurelio is right - MessageBus looks to be the best to achieve your requirement.

    There are some online examples as well.
    http://examples2.ext.net/#/MessageBus/Basic/Simple/
    http://examples2.ext.net/#/MessageBus/Basic/Complex/

    MessageBus can work with iframes as well.
    http://forums.ext.net/showthread.php...ll=1#post78276
  4. #4
    Sounds perfect. Within the code behind SubmitButton_Click I execute the following:

       X.AddScript("parentAutoLoadControl.hide()");
       MessageBus.Default.Publish("refresh", "Please refresh the grid");
    I have not added a listener anywhere yet, because the code is hanging on the call to MessageBus.Default.Publish. Am I missing something?
  5. #5
    Hi, the comand:
    MessageBus.Default.Publish("refresh", "Please refresh the grid");

    is Ok, you have Publish on a messageBus the message called "Refresh" with the parameter: "Please refresh the grid" in this case is a String parameter.

    In the grid you must refresh, insert the comand:
    <MessageBusListeners>
                        <ext:MessageBusListener
                            Name="refresh"
                            Handler="Call a method to refresh the grid;" //data = parameter, in this case you send a string "Please refresh the grid"
                            />
                    </MessageBusListeners>
    This comand receved only the message called "refresh", publish on the button, if another component send a message on a messagebus called "refresh" obviously the message is intercepted by the grid, i use name unique for the message in this way the message is intercepted only by the affected component.
    I hope it was helpful, sorry for my bad English.

    Thanks
    Aurelio
  6. #6
    For testing purposes does there have to be a receiving listener? I added the publish in my behind code but the window is no longer hiding. If I take out the MessageBus.Default.Publish it hides. Any thoughts?

    protected void SubmitButton_Click(object sender, DirectEventArgs e)
    {
        // Do something since the submit button was pressed;
    
        //  Hide the window and publish a message on the bus.
        X.AddScript("parentAutoLoadControl.hide()");
       MessageBus.Default.Publish("refresh", "Please refresh the grid");
    }
  7. #7
    Yes, Aurelio is right. You should listen a MessageBus event that you publish.

    Example Parent Page
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "test1" },
                    new object[] { "test2" },
                    new object[] { "test3" }
                };
                store.DataBind();
            }
        }
    </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>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Window ID="Window1" runat="server" Hidden="true">
                <Loader runat="server" Mode="Frame" Url="Test.aspx">
                    <LoadMask ShowMask="true" />
                </Loader>
            </ext:Window>
    
            <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
                <Store>
                    <ext:Store runat="server">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="test" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="Test" DataIndex="test" Width="200">
                            <Renderer Handler="return value + ' _ ' + Ext.Date.now();" />
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <MessageBusListeners>
                    <ext:MessageBusListener Name="refresh" Handler="alert(data); this.getView().refresh();" />
                </MessageBusListeners>
            </ext:GridPanel>
    
            <ext:Button runat="server" Text="Open Window with iframe">
                <Listeners>
                    <Click Handler="App.Window1.show();" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
    Example Child Page
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Close(object sender, DirectEventArgs e)
        {
            X.Js.AddScript("parentAutoLoadControl.hide();");
            MessageBus.Default.Publish("refresh", "Click OK to refresh the grid.");
        }
    </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:Button runat="server" Text="Close the Window" OnDirectClick="Close" />
    </body>
    </html>
    Last edited by Daniil; May 02, 2012 at 9:37 PM.
  8. #8
    Thank you very much for the example. Once I changed the code to hide the popup from:

    X.AddScript("parentAutoLoadControl.hide()");
    to
    X.Js.AddScript("parentAutoLoadControl.hide();");
    everything worked.

    Please close the thread.
  9. #9
    Quote Originally Posted by cwolcott View Post
    X.AddScript("parentAutoLoadControl.hide()");
    I think it should work as well if you would add semicolon at the end.
    X.AddScript("parentAutoLoadControl.hide();");
  10. #10
    Argh, damn semicolons.
    My eyes are failing me. It does work.

    Please close thread.
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: Jun 18, 2012, 3:41 PM
  2. [CLOSED] How to remove 'X' (window close) for popup window?
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 31, 2011, 3:50 AM
  3. [CLOSED] Button event is not firing in parent window from popup window
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 14, 2011, 7:35 PM
  4. Replies: 1
    Last Post: Mar 14, 2011, 4:20 PM
  5. Replies: 1
    Last Post: Mar 11, 2011, 10:07 PM

Posting Permissions