[CLOSED] Desktop window close button on toolbar

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Desktop window close button on toolbar

    Hi,
    is it possible to close a desktop window create dynamiccaly from a button on a toolbar inside the iframe loaded in the window ?

    thaks
    Luca Lusetti
  2. #2

    RE: [CLOSED] Desktop window close button on toolbar

    Hi Luca,

    Does the following forum post help solve the problem, see*http://forums.ext.net/showthread.php?postid=2155.aspx


    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] Desktop window close button on toolbar

    Hi Geoffrey,
    my situation is a bit diffenent. I'm trying to implement a desktoplike applicatiopn using Coolite.Desktop in ASP.NET MVC.
    Here is my scenario, I have a page loaded after user login that contains my desktop

    <ext:Desktop ID="MyDesktop" runat="server" BackgroundColor="Black">
    in the same page I've defined this functiopn to dynamically open windows without defining them as controls on the page.

    function OpenDeskWindow(title, webUrl, width, height, config) {
                var desk = MyDesktop.getDesktop();
                
                if (config == null)
                    config = {};              
                if (config.autoLoad == null)
                    config.autoLoad = {};
                
                Ext.applyIf(config, {
                        title: title,
                        width: width,
                        height: height,
                        maximizable: true,
                        minimizable: true,                   
                    })
                
                Ext.applyIf(config.autoLoad, {
                            url: webUrl,
                            mode: "iframe",
                            showMask: true
                            });
                var w = desk.createWindow(config);                                                
                w.center();
                w.show();            
            }
    From the opened window i can open a new window in the desk using a call like this

    parent.OpenDeskWindow();
    but from the opened window (inside iframe) I'm only able to close the window with a call like this

    parent.MyDesktop.getDesktop().getManager().getActive().hide();
    and even with this solution if I focus a different window and click on a button on a inactive window that call the above function window isn't the one active and I close the wrong one.

    I must admit that this is my first project using Coolite/ExtJs and making extensive use of javascript, so any help is really appreciated.
  4. #4

    RE: [CLOSED] Desktop window close button on toolbar

    Hi,

    You can pass to the iframe a window reference
    w.on("render", function(){this.iframe.dom.contentWindow.parentWindow = this;}, w, {delay:10});
    and using this reference in the iframe to close the window
    <Click Handler="parentWindow.close();" />
    Here is a sample
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!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></title>
        <script type="text/javascript">
            function openW(){
                var config = {
                    title: "title",
                    width: 300,
                    height: 300,
                    maximizable: true,
                    minimizable: true,
                    autoLoad:{
                        url: "subpage.aspx",
                        mode: "iframe",
                        showMask: true
                    }
                };              
                
                var w = new Ext.Window(config);  
                w.on("render", function(){this.iframe.dom.contentWindow.parentWindow = this;}, w, {delay:10});                                                          
                
                w.show();            
                w.center();
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        
            <ext:ScriptManager ID="ScriptManager1" runat="server">        
            </ext:ScriptManager>    
            
            <ext:Button runat="server" Text="Open">
                <Listeners>
                    <Click Handler="openW();" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
    subpage.aspx
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!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></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
        
            <ext:Button runat="server" Text="Close">
                <Listeners>
                    <Click Handler="parentWindow.close();" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
  5. #5

    RE: [CLOSED] Desktop window close button on toolbar

    Hi again,
    I was a bit busy with other stuff to fix and didn't have a chance to test it before today. I tested the code and isn't working for me.

    My page is an ASP.NET MVC view, can this cause problems to the proposed solution ?

    Luca Lusetti
  6. #6

    RE: [CLOSED] Desktop window close button on toolbar

    Hi,

    What problems do you have? Do you have any javascript errors?


    The forum engine replaced some letters to lowercase. Please note


    1. Need use contentWindow (upper case W)
    w.on("render", function(){this.iframe.dom.contentWindow.parentWindow = this;}, w, {delay:10});

    2.*parentWindow (upper case W)
    <Click Handler="parentWindow.close();" />
  7. #7

    RE: [CLOSED] Desktop window close button on toolbar

    Hi,

    I fixed original sample (now W with correct case)*
  8. #8

    RE: [CLOSED] Desktop window close button on toolbar

    I wasn't getting any error (using firefox with firebug). Now I checked with correct "W". Still isn't working.

    I've made some tests

    w.on("render", function(){alert("render"); this.iframe.dom.contentWindow.parentWindow = this;}, w, {delay:10});
    w.on("activate", function(){alert("activate"); this.iframe.dom.contentWindow.parentWindow = this;}, w, {delay:10});
    render alert is never displayed, activate alert is displayed every time I change window (as expected).

    The window I load contains a store that is updated as soon as the page loads. Can this interfer with the render event ?

       <ext:Store ID="dsUtente" runat="server" ShowWarningOnFailure="True">
            <Proxy>
                <ext:HttpProxy Url="/Amministrazione/Utenti/GetUtente" />
            </Proxy>
            <Reader>
                <ext:JsonReader ReaderID="Id" Root="data" TotalProperty="totalCount">
                    <Fields>
                        <ext:RecordField Name="Id" />
                        <ext:RecordField Name="Cognome" />
                        <ext:RecordField Name="Nome" />
                        <ext:RecordField Name="Email" />
                        <ext:RecordField Name="Username" />
                        <ext:RecordField Name="Password" />                    
                    </Fields>
                </ext:JsonReader>
            </Reader>
            <BaseParams>            
                <ext:Parameter Name="id" Value="#{loadId}.getValue()" Mode="Raw" />
            </BaseParams>
            <Listeners>
                <BeforeLoad Handler="#{detailsForm}.el.mask('Caricamento utente...', 'x-mask-loading');" />
                <LoadException Handler="#{detailsForm}.el.unmask();" />
                <Load Fn="recordLoaded" />
            </Listeners>
        </ext:Store>
  9. #9

    RE: [CLOSED] Desktop window close button on toolbar

    Hi,

    Does this problem occur in my example? If not then can you create simple example which reproduce this problem. It is strange because without render event a window can't be created*
  10. #10

    RE: [CLOSED] Desktop window close button on toolbar

    I've created a simple asp.net website. Tested your code and it works perfectly. So must be somethiong in my page that breaks it. Well I paste here my view code maybe you can point me in the good direction

    <%@ Page Language="C#" MasterPageFile="~/Views/Shared/View.Master" Inherits="System.Web.Mvc.ViewPage" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <asp:Content ContentPlaceHolderID="headContent" runat="server">
        <script type="text/javascript">                
            var commandHandler = function(cmd, record) {
                switch (cmd) {
                    case "edit":
                        openDetails(record.data.Id, 'Scheda Utente : ' + record.data.Cognome + ' ' + record.data.Nome);
                        break;
                    case "delete":
    
                        Ext.Msg.confirm('Alert', 'Eliminare il record?', function(btn) {
                            if (btn == "yes") {
                                Ext.Ajax.request({
                                    url: '/Amministrazione/Utenti/Elimina',
                                    success: function(response) {                                    
                                        dsList.reload();
                                    },
                                    failure: function(response) {
                                        var msg = '';
                                        if (result.extraParams.msg) {
                                            msg = result.extraParams.msg;
                                        } else if (response) {
                                            msg = response.responseText;
                                        }
                                        Ext.Msg.show({
                                            title: 'Errore durante l\'esecuzione dell\'operazione',
                                            msg: msg,
                                            buttons: Ext.Msg.OK,
                                            icon: Ext.Msg.ERROR
                                        });
                                        dsList.reload();
                                    },
                                    params: { id: record.data.Id }
                                });
    
                            }
                        });
                        break;
                }
            }
    
            function openDetails(recordId, title) {
                config = {
                    autoLoad: {
                        params: {
                            'id': recordId
                        }
                    },                
                    listeners: {
                        hide: function() { dsList.reload(); }
                    }
                };
                
                parent.OpenDeskWindow(title, '/Amministrazione/Utenti/Modifica', 500, 400, config);            
            }
    
            function newUser() {
                openDetails(-1, 'Scheda Utente : Nuovo');
            }
        </script>
    </asp:Content>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="mainContent" runat="server">
        <ext:Store ID="dsList" runat="server" RemoteSort="False">
            <Proxy>
                <ext:HttpProxy Url="/Amministrazione/Utenti/GetElencoUtenti" />
            </Proxy>        
            <Reader>
                <ext:JsonReader ReaderID="Id" Root="data" TotalProperty="totalCount">
                    <Fields>
                        <ext:RecordField Name="Id" SortDir="ASC"/>
                        <ext:RecordField Name="Username" />                    
                        <ext:RecordField Name="Email" />                    
                        <ext:RecordField Name="Cognome" />       
                        <ext:RecordField Name="Nome" />                           
                    </Fields>
                </ext:JsonReader>
            </Reader> 
            <BaseParams>
                <ext:Parameter Name="limit" Value="15" Mode="Raw" />
                <ext:Parameter Name="start" Value="0" Mode="Raw" />            
            </BaseParams>       
            <SortInfo Field="Id" Direction="ASC" />
        </ext:Store>
        
        <ext:ViewPort ID="viewport" runat="server">
            <Body>
                <ext:FitLayout ID="viewportFitLayout" runat="server">
                    <ext:GridPanel 
                        ID="gridUsers" 
                        runat="server" 
                        Header="false"
                        Border="false"
                        StoreID="dsList"
                        TrackMouseOver="true"
                        ClicksToEdit="1"
                        AutoExpandColumn="Email">
                        <ColumnModel ID="cmGridUsers" runat="server">
                            <Columns>
                                <ext:Column ColumnID="Id" DataIndex="Id" Header="ID" Hidden="true" />                            
                                <ext:Column ColumnID="Cognome" DataIndex="Cognome" Header="Cognome" />
                                <ext:Column ColumnID="Nome" DataIndex="Nome" Header="Nome" />         
                                <ext:Column ColumnID="Username" DataIndex="Username" Header="Username" />   
                                <ext:Column ColumnID="Email" DataIndex="Email" Header="Email" />                                                                                                                                                                                                
                                <ext:CommandColumn Width="25" Hideable="false">
                                    <Commands>
                                        <ext:GridCommand CommandName="edit" Icon="ApplicationFormEdit">
                                            <ToolTip Text="Modifica" />
                                        </ext:GridCommand>
                                    </Commands>                                
                                </ext:CommandColumn>
                                <ext:CommandColumn Width="25" Hideable="false">
                                    <Commands>
                                        <ext:GridCommand CommandName="delete" Icon="Cross">
                                            <ToolTip Text="Elimina" />
                                        </ext:GridCommand>
                                    </Commands>                                
                                </ext:CommandColumn>
                            </Columns>
                        </ColumnModel>
                        <TopBar>
                            <ext:Toolbar ID="tbGridUsers" runat="server">
                                <Items> 
                                    <ext:ToolbarButton ID="btmChiudi" runat="server" Text="" Icon="DoorOut">
                                        <Listeners>
                                            <Click Fn="closeWindow" />
                                        </Listeners>
                                    </ext:ToolbarButton>  
                                    <ext:ToolbarSeparator />                               
                                    <ext:Button ID="btnAddUser" runat="server" Text="Nuovo" Icon="Add">
                                        <Listeners>
                                            <Click Handler="newUser();" />
                                        </Listeners>
                                    </ext:Button>                                
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                        <BottomBar>
                            <ext:PagingToolbar ID="ptGridUsers" runat="server" StoreID="dsList" PageSize="15" />
                        </BottomBar>
                        <Listeners>
                            <Command Fn="commandHandler" />                        
                        </Listeners>
                        <LoadMask ShowMask="true" />
                        <SaveMask ShowMask="true" />
                    </ext:GridPanel>
                </ext:FitLayout>
            </Body>
        </ext:ViewPort>            
    </asp:Content>
    and this is the master page

    <%@ Import Namespace="CedHouseSuite.Web.Extensions"%>
    <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!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>CedHouse Suite</title>
        <ext:ScriptContainer runat="server" />        
        <asp:ContentPlaceHolder ID="headContent" runat="server"></asp:ContentPlaceHolder>
        <script type="text/javascript">
            var openLog = function(entityId, entityName) {
                parent.OpenLogWindow(entityId, entityName);                
            }
            
            
            var closeWindow = function(btn, eo) {
                parentWindow.close();
                //parent.MyDesktop.getDesktop().getManager().getActive().hide();
            }
            
        </script>
    </head>
    <body>
        <ext:ScriptManager ID="viewScriptManager" runat="server" Locale="it-IT" />
        <asp:ContentPlaceHolder ID="mainContent" runat="server"></asp:ContentPlaceHolder>         
    </body>
    </html>
    edited: added master page code
Page 1 of 2 12 LastLast

Similar Threads

  1. Create a button to close a window
    By Orwel in forum 2.x Help
    Replies: 2
    Last Post: Aug 10, 2012, 12:16 PM
  2. [CLOSED] how to close window after click button in this window
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Jun 22, 2012, 2:48 PM
  3. [CLOSED] Desktop Window | Toolbar | Dropdownfield Component
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Feb 01, 2010, 3:49 PM
  4. Desktop window Close
    By Richardt in forum 1.x Help
    Replies: 1
    Last Post: Aug 25, 2009, 5:11 PM
  5. Replies: 4
    Last Post: Jun 03, 2009, 5:24 PM

Posting Permissions