[CLOSED] Finding a menu with Ext.getCmp()

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Finding a menu with Ext.getCmp()



    If I add a menu to the page (in code behind) with something like this

        Cool.Menu myMenu = new Cool.Menu();
        myMenu.ID = "myMenuID";
        myMenu.Items.Add (...)
    What gets rendered is something like this:

    this.myMenuId = new Ext.menu.Menu({
            proxyId: "myMenuId",
            items: [new Ext.menu.Item({   ...    })]  });
    But when I try and find the menu by id with the following code, I can't find it

        var myMenu = Ext.getCmp('myMenuId');
    I assume this is because the menu is rendered (for some reason) with a proxyId rather than just an Id.

    How can I find a menu using the Ext.getCmp() function?

  2. #2

    RE: [CLOSED] Finding a menu with Ext.getCmp()

    Hi,

    Ext.getCmp can't be used for getting Menu because Menu is not inherited from Component class
    You can use window object to get menu instance


    window['Menu1']
  3. #3

    RE: [CLOSED] Finding a menu with Ext.getCmp()

    OK, Thanks
  4. #4

    RE: [CLOSED] Finding a menu with Ext.getCmp()

    Just a quick note... with the v1.0 release (ExtJS 3.x), Menu has been changed to inherit from Component, so using .getCmp() will be supported at that point.

    Geoffrey McGill
    Founder
  5. #5

    RE: [CLOSED] Finding a menu with Ext.getCmp()

    Geoffrey;

    Thanks thats interesting. It may relate to another problem I'm having getting a toolbar menu to drop down on a mouse hover. Cant seem to get this working, and on the ExtJS Forum they say this is resolved in ExtJs 3.x.

    Which begs the obvious question: When can we expect to see ExtJS 3.x integrated with Coolite?
  6. #6

    RE: [CLOSED] Finding a menu with Ext.getCmp()

    hi.. have a same problem,
    not find component :(

    this is my code:

    
    <%@ Page Language="VB" Theme="unisys" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
    
    <!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>Pagina senza titolo</title>
        <link rel="stylesheet" type="text/css" href="css/ext-all.css" />
        <script type="text/javascript" src="js/ext2/ext-base.js"></script>
         <!-- ENDLIBS -->
    
        <script type="text/javascript" src="js/ext2/ext-all.js"></script>
        
         <script type="text/javascript">
                /*
                 * Ext JS Library 2.2.1
                 * Copyright(c) 2006-2009, Ext JS, LLC.
                 * licensing@extjs.com
                 * 
                 * http://extjs.com/license
                 */
    
                Ext.onReady(function(){
                    var p = new Ext.Panel({
                        title: 'My Panel',
                        id: "test",
                        collapsible:true,
                        renderTo: 'container',
                        width:400,
                        height:300
                        //html: Ext.example.bogusMarkup
                    });
                });
            </script>
    
    </head>
    <body>
        <form id="form1" runat="server">
            
           
            
            <div id="container">
        
            
    
            
            <script type="text/javascript">
                alert(Ext.getCmp('test'));
            </script>
    
        </form>
    </body>
    </html>

    Ext.getCmp('test') is undefinided :(
  7. #7

    RE: [CLOSED] Finding a menu with Ext.getCmp()

    Hi,

    You call alert function immediately when page load but your test panel is created only when JS DOM ready. So, you call alert when panel is not created yet.


    It would also be best to create a new topic.


  8. #8

    RE: [CLOSED] Finding a menu with Ext.getCmp()

    Hi maxdiable,

    You should wrap your alert function inside an Ext.onReady.


    If your code, at the point .alert is called, the Panel has not been instantiated and does not exist yet. If the alert is placed in an Ext.onReady, the alert should be called after the Panel has been rendered.


    Hope this helps.


    Geoffrey McGill
    Founder
  9. #9

    RE: [CLOSED] Finding a menu with Ext.getCmp()

    tank's :)

    but.. it's impossible find the compenent after his creation ?

    tank's...
  10. #10

    RE: [CLOSED] Finding a menu with Ext.getCmp()

    The following appears to work as expected.

    Example

    <%@ 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>Pagina senza titolo</title>
        
        <ext:ScriptContainer runat="server" />
        
        <script type="text/javascript">
            /*
             * Ext JS Library 2.2.1
             * Copyright(c) 2006-2009, Ext JS, LLC.
             * licensing@extjs.com
             * 
             * http://extjs.com/license
             */
    
            Ext.onReady(function(){
                var p = new Ext.Panel({
                    title: 'My Panel',
                    id: "test",
                    collapsible:true,
                    renderTo: 'container',
                    width:400,
                    height:300
                    //html: Ext.example.bogusMarkup
                });
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ScriptManager runat="server" />
           
            <div id="container">
    
            
            <script type="text/javascript">
                Ext.onReady(function () {
                    alert(Ext.getCmp('test'));
                });
            </script>
    
        </form>
    </body>
    </html>
    Hope this helps.

    Geoffrey McGill
    Founder
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 5
    Last Post: Jul 31, 2012, 2:36 PM
  2. [CLOSED] Ext.Net.X.GetCmp - how to call in parent?
    By wagger in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 25, 2011, 4:55 AM
  3. [CLOSED] Custom Search with X.GetCmp
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Feb 15, 2011, 4:46 PM
  4. Finding dirty rows in a gridpanel
    By Kamal in forum 1.x Help
    Replies: 2
    Last Post: Aug 16, 2009, 9:51 AM
  5. Finding GridPanel in a TabPanel
    By madhugumma in forum 1.x Help
    Replies: 0
    Last Post: Jul 22, 2009, 9:59 AM

Posting Permissions