Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: find object region with javascript

  1. #1

    Exclamation find object region with javascript

    hi,

    i have a viewport and all region in my masterpage, and i want find east region with javascript...

    it's possible ?

    regards

  2. #2
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,488

    Default

    The easiest way is to give your east region an id configuration like so:

    Code:
    id: 'myEastPanel',
    Then you can retrieve it with the ComponentMgr:
    Code:
    var eastPanel = Ext.getCmp('myEastPanel');
    Aaron Conran
    @aconran

  3. #3

    Smile tanks

    tanks
    regards

  4. #4

    Exclamation question ?? for Ext.get

    i have this page:

    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.
                 * [email protected]
                 * 
                 * 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">
        
            </div>
            
            <script type="text/javascript">
                alert(Ext.get('test'));
            </script>
    
        </form>
    </body>
    </html>
    but the Ext.get('test') is undefinided ....

    help me

  5. #5
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Default

    References to Components are retrieved by Ext.getCmp.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  6. #6
    Ext JS Premium Member
    Join Date
    Aug 2009
    Posts
    92

    Default

    This doesn't work. A Region is not a Panel. Particularly, you can't get a Region via Ext.getCmp, because it's not a Component.

    Any other way to do it? This is driving me nuts.

    Code:
    myPanel = Ext.extend(Ext.Panel, {
        initComponent: function() {
           var config = {
                layout: 'border',
                items: [{
                    region: 'south',
                    collapsible: true,
                    collapsed: true,
    /*...*/
                },{
                    region: 'center',
                    layout:'hbox',
    /*...*/
                }]
            };
            
            Ext.apply(this, config);
        
            myPanel.superclass.initComponent.apply(this, arguments);
        },
    
        doSomething: function() {
            var southRegion = ???
            if (southRegion. isCollapsed) {
                 // some important stuff...
            }
        }
    });

  7. #7
    Ext JS Premium Member
    Join Date
    Aug 2009
    Posts
    92

    Default

    After some search, I found a solution:

    Code:
    var southRegion = this.getLayout().south;
    Too bad this is not in the docs

  8. #8
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    It's not documented, because I don't see a reason why somebody would want a reference to a region.

    Unless you want a reference to the component:
    Code:
    var southComponent = this.getLayout().south.panel;

  9. #9
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,488

    Default

    Quote Originally Posted by Tom23 View Post
    After some search, I found a solution:

    Code:
    var southRegion = this.getLayout().south;
    Too bad this is not in the docs
    This is the correct way to grab the BorderLayout.Region of a given owner container. What do you need this for though? It's typically not a class which end level developers use.
    Aaron Conran
    @aconran

  10. #10
    Ext JS Premium Member
    Join Date
    Aug 2009
    Posts
    92

    Default

    In my example code above, the doSomething method should run only if the lower pane is collapsed. I can't find a way to check this without using
    Code:
    southRegion.isCollapsed
    Edit: ok, I could use
    Code:
    southRegion.panel.collapsed
    which is about the same thing.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •