PDA

View Full Version : find object region with javascript



maxdiable
13 Jun 2009, 3:29 AM
hi,

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

it's possible ?

regards

aconran
14 Jun 2009, 6:03 AM
The easiest way is to give your east region an id configuration like so:



id: 'myEastPanel',


Then you can retrieve it with the ComponentMgr:


var eastPanel = Ext.getCmp('myEastPanel');

maxdiable
14 Jun 2009, 7:10 AM
tanks :)
regards

maxdiable
21 Jun 2009, 9:00 AM
i have this page:




<%@ 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 :(

hendricd
21 Jun 2009, 10:21 AM
References to Components are retrieved by Ext.getCmp.

Tom23
10 Sep 2009, 12:55 AM
This doesn't work. A Region (http://www.extjs.com/deploy/ext-2.2/docs/?class=Ext.layout.BorderLayout.Region&member=isCollapsed) 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.


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...
}
}
});

Tom23
10 Sep 2009, 1:54 AM
After some search, I found a solution:


var southRegion = this.getLayout().south;Too bad this is not in the docs (http://www.extjs.com/deploy/dev/docs/?class=Ext.layout.BorderLayout)

Condor
10 Sep 2009, 1:58 AM
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:

var southComponent = this.getLayout().south.panel;

aconran
10 Sep 2009, 5:03 AM
After some search, I found a solution:


var southRegion = this.getLayout().south;Too bad this is not in the docs (http://www.extjs.com/deploy/dev/docs/?class=Ext.layout.BorderLayout)

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.

Tom23
10 Sep 2009, 7:38 AM
In my example code above (http://www.extjs.com/forum/showthread.php?p=384982#post384982), the doSomething method should run only if the lower pane is collapsed. I can't find a way to check this without using
southRegion.isCollapsed

Edit: ok, I could use

southRegion.panel.collapsed
which is about the same thing.

aconran
10 Sep 2009, 7:40 AM
Subscribe to the collapse and expand events of the Ext.Panel.

http://www.extjs.com/deploy/dev/docs/?class=Ext.Panel

Animal
10 Sep 2009, 7:54 AM
Panel.collapsed is a documented property. It's what you should use.

The Region class is a manager class which manages Panels for the BorderLayout class.

Tom23
10 Sep 2009, 9:27 AM
So, should Ext.layout.BorderLayout.Region.isCollapsed be removed from the docs? It gave me the impresion I should use it. But as I take it from the source code, region.isCollapsed has always the same value as region.panel.collapsed.