[CLOSED] Desktop Menu Open Page

  1. #1

    [CLOSED] Desktop Menu Open Page

    Hello to All

    I am using Desktop component, made ​​a dynamic menu, until there everything is working correctly, so I can not make him run the call from the page when I click an option from the menu, I'm tenatdo do with Listeners.

    I can call an aspx or ascx page only?

    Can anyone help me with this?

    Follows the code I'm using:

    Page aspx.

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Desktop.aspx.cs" Inherits="Desktop" %>
    
    <%@ Register src="winCompany.ascx" tagname="winCompany" tagprefix="uc1" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server">
            </ext:ResourceManager>
            <ext:Desktop ID="Desktop1" runat="server">
                <TaskBar runat="server" StartBtnText="Iniciar" StartBtnIconCls="#AsteriskOrange" StyleHtmlContent="False" />
    
                <StartMenu Title="Sistema Integrado de Imobiliarias" Icon="Application" Height="300">
    
                    <MenuItems>
                        <ext:MenuItem ID="MainMenu" runat="server" Text="Menu do Sistema" Icon="Folder">
                        </ext:MenuItem>
                        <ext:MenuItem runat="server" Text="Add module">
                            <%--                        <DirectEvents>
                                <Click Url="/Test/AddModule1" Before="this.disable();">
                                    <ExtraParams>
                                        <ext:Parameter Name="desktopId" Value="Desktop1" Mode="Value" />
                                    </ExtraParams>
                                </Click>
                            </DirectEvents>--%>
                            <Listeners>
                                <Click Handler="#{winCompany}.show();" />
                            </Listeners>
                        </ext:MenuItem>
                    </MenuItems>
                    <Items>
                        <ext:MenuItem Text="Ulisses">
                            <Menu>
                                <ext:Menu ID="Menu1" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItem2" runat="server" Text="Child Item 001.1">
                                            <Listeners>
                                                <Click Handler="alert('001');"></Click>
                                            </Listeners>
                                        </ext:MenuItem>
                                        <ext:MenuItem ID="MenuItem3" runat="server" Text="Child Item 001.2">
                                            <Listeners>
                                                <Click Handler="alert('002');"></Click>
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:MenuItem>
                    </Items>
                    <ToolConfig>
                        <ext:Toolbar runat="server" Width="100">
                            <Items>
                                <ext:Button runat="server" Text="Settings" Icon="Cog" />
                                <ext:Button runat="server" Text="Logout" Icon="Key">
                                    <DirectEvents>
                                                <Click OnEvent="Logout_Click">
                                            <EventMask ShowMask="true" Msg="Good Bye..." MinDelay="1000" />
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </ToolConfig>
                </StartMenu>
            </ext:Desktop>
        </form>
    </body>
    </html>
    Code C#
    using BusinessObjects;
    using Ext.Net;
    using MySql.Data.MySqlClient;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class Desktop : System.Web.UI.Page
    {
        int menuValue = 1;
        int incValue = 1;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
               buildMenu();
            }
    
        }
    
        private void buildMenu()
        {
            Ext.Net.Menu SubMenu = new Ext.Net.Menu();
            Ext.Net.MenuItem SubMenuFolder;
    
            string ConnectionString = "Database=ucaneto_imobiliaria;Data Source=baratheon0101.hospedagemdesites.ws;User Id=ucane_imobil;Password=s;";
            MySqlConnection con = new MySqlConnection(ConnectionString);
    
            string sqlstatment = "select * from TblMenu ";
            MySqlDataAdapter adapter = new MySqlDataAdapter(sqlstatment, con);
            DataSet ds = new DataSet();
            adapter.Fill(ds, "vw_menu");
    
            if (ds.Tables[0].Rows.Count > 0)
            {
                SubMenu.ID = "SubMenu";
                MainMenu.Menu.Add(SubMenu);
            }
    
            ds.Relations.Add("NodeRelation", ds.Tables[0].Columns["ID"], ds.Tables[0].Columns["IdPai"]);
            foreach (DataRow dbRow in ds.Tables[0].Rows)
            {
                if (dbRow.IsNull("IdPai"))
                {
                    SubMenuFolder = new Ext.Net.MenuItem();
                    SubMenuFolder.ID = dbRow["Menu"].ToString();
                    SubMenuFolder.Icon = ParseEnum<Icon>(dbRow["Icone"].ToString());
                    SubMenuFolder.Text = dbRow["Menu"].ToString();
                    SubMenu.Items.Add(SubMenuFolder);
    
                    incValue = 1;
                    this.PopulateSubItem(dbRow, SubMenuFolder);
                }
            }
        }
    
        private void PopulateSubItem(DataRow dbRow, Ext.Net.MenuItem itm)
        {
            Ext.Net.MenuItem childitm;
            Ext.Net.Menu SubSubMenu = new Ext.Net.Menu();
            foreach (DataRow childRow in dbRow.GetChildRows("NodeRelation"))
            {
                if ((int)childRow["IdPai"] == 0)
                {
                    SubSubMenu.ID = "SubSubMenu" + menuValue.ToString();
                    itm.Menu.Add(SubSubMenu);
    
                    childitm = new Ext.Net.MenuItem();
                    childitm.ID = childRow["Menu"].ToString();
                    childitm.Icon = ParseEnum<Icon>(childRow["Icone"].ToString());
                    childitm.Text = childRow["Menu"].ToString();
                    SubSubMenu.Items.Add(childitm);
    
                    incValue = 1;
                }
                else
                {
                    if (incValue == 1)
                    {
                        SubSubMenu.ID = "SubSubMenu" + menuValue.ToString();
                        itm.Menu.Add(SubSubMenu);
                    }
    
    
                    childitm = new Ext.Net.MenuItem();
                    childitm.ID = childRow["Menu"].ToString();
                    childitm.Icon = ParseEnum<Icon>(childRow["Icone"].ToString());
                    childitm.Text = childRow["Menu"].ToString();
                    if (!string.IsNullOrEmpty(childRow["Formulario"].ToString()))
                        childitm.Listeners.Click.Handler = "#{" + childRow["Formulario"].ToString() + "}.show();"; //Here I try to make a call page
                    SubSubMenu.Items.Add(childitm);
    
                    incValue = 0;
                }
    
                menuValue += menuValue;
                this.PopulateSubItem(childRow, childitm);
            }
        }
    
        [DirectMethod]
        public void Logout_Click(object sender, DirectEventArgs e)
        {
        }
    }
    Last edited by Daniil; Jul 01, 2014 at 2:46 PM. Reason: [CLOSED]
  2. #2
    Hi @ucaneto,

    Sorry, I don't quite understand the requirement.

    Please elaborate on what you need to do on MenuItem click.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @ucaneto,

    Sorry, I don't quite understand the requirement.

    Please elaborate on what you need to do on MenuItem click.
    Hi


    I would like to call to open a window with an aspx or ascx page. Except that when I click does nothing, how do this?


    The other question is should I use aspx or ascx page?
  4. #4
    Quote Originally Posted by ucaneto View Post
    I would like to call to open a window with an aspx or ascx page. Except that when I click does nothing, how do this?
    As far as I can understand you need to render a DesktopModule on the fly. Please see this example:
    https://examples2.ext.net/#/Desktop/...tion/Overview/

    Please look at:
    [DirectMethod(ShowMask = true)]
    public void AddNewModule()
    {
        Desktop.GetInstance().RemoveModule("add-module");
        DesktopModuleProxy control = Ext.Net.Utilities.ControlUtils.FindControl<Ext.Net.DesktopModuleProxy>(this.LoadControl("modules/TabWindow.ascx"));
        control.RegisterModule();
    }
    TabWindow.ascx
    <%@ Control Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <ext:DesktopModuleProxy runat="server">
        <Module ModuleID="tab-win">
            <Shortcut Name="Tab Window" />
            <Launcher Text="Tab Window" Icon="Tab" />
            <Window>
                <ext:Window runat="server"
                    Icon="Tab"
                    Width="740" 
                    Height="480" 
                    ConstrainHeader="true"         
                    Border="false"       
                    Layout="Fit"
                    Title="Tab Window">
                    <Items>
                        <ext:TabPanel runat="server" ActiveTabIndex="0" BodyStyle="padding:5px;">
                            <Items>
                                <ext:Panel runat="server" Title="Tab Text 1" Border="false" Html="<p>Something useful would be in here.</p>">                            
                                </ext:Panel>
    
                                <ext:Panel runat="server" Title="Tab Text 2" Border="false" Html="<p>Something useful would be in here.</p>">                            
                                </ext:Panel>
    
                                <ext:Panel runat="server" Title="Tab Text 3" Border="false" Html="<p>Something useful would be in here.</p>">                            
                                </ext:Panel>
    
                                <ext:Panel runat="server" Title="Tab Text 4" Border="false" Html="<p>Something useful would be in here.</p>">                            
                                </ext:Panel>
                            </Items>
                        </ext:TabPanel>
                    </Items>
                </ext:Window>
            </Window>
        </Module>
    </ext:DesktopModuleProxy>
    Quote Originally Posted by ucaneto View Post
    The other question is should I use aspx or ascx page?
    Well, it depends on your requirements. Though, if use .aspx it means that you'll use iframes. We would recommend you not to use iframes unless you really-really need that. So, if you don't need it, .ascx is a way to go.
  5. #5
    What I'm also not getting is how to program the Listeners.Click
    in my code like this
    
    if (! string.IsNullOrEmpty (childRow ["Form"]. ToString ())) 
                         childitm.Listeners.Click.Handler = "# {". + childRow ["Form"] ToString () + "}. mes ();" / / Here I try to make a call page

    Only this not running.

    Ulisses
    Quote Originally Posted by Daniil View Post
    Hi @ucaneto,

    Sorry, I don't quite understand the requirement.

    Please elaborate on what you need to do on MenuItem click.
    Quote Originally Posted by Daniil View Post
    As far as I can understand you need to render a DesktopModule on the fly. Please see this example:
    https://examples2.ext.net/#/Desktop/...tion/Overview/

    Please look at:
    [DirectMethod(ShowMask = true)]
    public void AddNewModule()
    {
        Desktop.GetInstance().RemoveModule("add-module");
        DesktopModuleProxy control = Ext.Net.Utilities.ControlUtils.FindControl<Ext.Net.DesktopModuleProxy>(this.LoadControl("modules/TabWindow.ascx"));
        control.RegisterModule();
    }
    TabWindow.ascx
    <%@ Control Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <ext:DesktopModuleProxy runat="server">
        <Module ModuleID="tab-win">
            <Shortcut Name="Tab Window" />
            <Launcher Text="Tab Window" Icon="Tab" />
            <Window>
                <ext:Window runat="server"
                    Icon="Tab"
                    Width="740" 
                    Height="480" 
                    ConstrainHeader="true"         
                    Border="false"       
                    Layout="Fit"
                    Title="Tab Window">
                    <Items>
                        <ext:TabPanel runat="server" ActiveTabIndex="0" BodyStyle="padding:5px;">
                            <Items>
                                <ext:Panel runat="server" Title="Tab Text 1" Border="false" Html="<p>Something useful would be in here.</p>">                            
                                </ext:Panel>
    
                                <ext:Panel runat="server" Title="Tab Text 2" Border="false" Html="<p>Something useful would be in here.</p>">                            
                                </ext:Panel>
    
                                <ext:Panel runat="server" Title="Tab Text 3" Border="false" Html="<p>Something useful would be in here.</p>">                            
                                </ext:Panel>
    
                                <ext:Panel runat="server" Title="Tab Text 4" Border="false" Html="<p>Something useful would be in here.</p>">                            
                                </ext:Panel>
                            </Items>
                        </ext:TabPanel>
                    </Items>
                </ext:Window>
            </Window>
        </Module>
    </ext:DesktopModuleProxy>


    Well, it depends on your requirements. Though, if use .aspx it means that you'll use iframes. We would recommend you not to use iframes unless you really-really need that. So, if you don't need it, .ascx is a way to go.
    Last edited by Daniil; Jun 24, 2014 at 1:33 PM. Reason: Please use [CODE] tags
  6. #6
    What does it produce?
    "# {". + childRow ["Form"] ToString () + "}. mes ();"
    I mean what is a result string?

Similar Threads

  1. Programmatically open start menu in desktop
    By markusn in forum 2.x Help
    Replies: 2
    Last Post: Mar 30, 2014, 1:27 PM
  2. Replies: 8
    Last Post: Jul 29, 2012, 10:58 AM
  3. Replies: 2
    Last Post: Feb 02, 2011, 2:25 PM
  4. Desktop menu and trigger
    By Richardt in forum 1.x Help
    Replies: 1
    Last Post: Jun 03, 2010, 1:14 PM
  5. Context menu on Desktop
    By flaviodamaia in forum 1.x Help
    Replies: 0
    Last Post: May 12, 2009, 9:42 AM

Posting Permissions