Problem with a inner layout and toolbar - Ext JS

作者在使用ExtJS框架时遇到布局与工具栏的问题,当尝试将布局添加到包含工具栏的内容面板中时出现JavaScript错误。通过调整布局管理器的配置及元素高度设置解决了部分问题,但仍存在布局计算不准确导致的显示错误。
I have a toolbar in content panel. I's works perfectly but when I put a layout in the container give me a js error.

My html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Hpanel v.4.0.0 - Harpra</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />


		<link rel="stylesheet" type="text/css" href="./yui-ext/resources/css/ext-all.css" />
		<link rel="stylesheet" type="text/css" href="./yui-ext/resources/css/ytheme-aero.css" />
		<link rel="stylesheet" type="text/css" href="./css/layout.css" />

	    <script type="text/javascript" src="./yui-ext/yui-utilities.js"></script>
	    <script type="text/javascript" src="./yui-ext/ext-all.js"></script>
	    <script type="text/javascript" src="./yui-ext/ext-bridge-yui.js"></script>

		<script language="javascript" src="./js/jquery.js"></script>


		<script language="javascript" src="./js/layout.js"></script>

		<script language="javascript" src="./modules/list_detail/js/layout.js"></script>
	</head>
	<body>

	<div id ="container">
	  	<div id="north" class="x-layout-inactive-content">
		  	<div id="header">
			  	<h1>Hpanel</h1>

			    <h2>v.4.0.0.alpha</h2>
		    </div>

		 </div>
		
<dl id="applicationMenu" style="display:none;">
	<dt>Escritorio</dt>		 		<dd>
			 		<ul>
				 		[*]A?adir Widget[*]Configurar cuenta[*]Email[*]Agenda					[/list]
				 </dd>
				 <dt>Administración</dt>		 		<dd>
			 		<ul>
				 		[*]Usuarios[*]Grupos[*]Objetos[*]Menu					[/list]				 </dd>

				 <dt>Gestión</dt>		 		<dd>
			 		<ul>
				 		[*]Proveedores[*]Facturas[*]Pedidos[*]Clientes					[/list]				 </dd>
				 
</dl>		<div id="applicationlayout" >

			<div id="toolbar"></div>

			<div id="contentpanel">
								<div id="nav" class="ylayout-inactive-content">
					izquierda
				</div>
				<div id="content" class="ylayout-inactive-content">
					derecha
				</div>			</div>

		</div>

	</div>
	</body>
</html>
My javascript:
applicationLayout = function(){
        var layout;
        return {
            init : function(){

            	var tb = new Ext.Toolbar('toolbar');
				tb.add({text:'Inicio'});

				//A?adimos los menus
				$("#applicationMenu").children().each(function () {

					switch (this.tagName) {
						case 'DT':
								//Creamos el menu
								menu = new Ext.menu.Menu('mainMenu');
								tb.add({text:$(this).children()[0].getAttribute('title'), menu: menu});
						break;

						case 'DD':
								$(this).find("ul li a").each(function(i) {
									menu.add({text: $(this).html()});
								});
						break;
					}

				});

               layout = new Ext.BorderLayout(document.body, {
                    hideOnLayout: true,
                    north: {
                        split:false,
                        initialSize: 63,
                        titlebar: false
                    },
                    center: {
						titlebar: false
				    }
                });

                layout.beginUpdate();
                layout.add('north',  new Ext.ContentPanel('north', 'North'));
				layout.add('center', new Ext.ContentPanel('applicationlayout',{
				     toolbar: tb,
				     resizeEl: 'contentpanel',
				     autoScroll:true,
				     fitToFrame:true
				}));
                layout.endUpdate();
           }

     };

}();


Ext.EventManager.onDocumentReady(applicationLayout.init, applicationLayout, true);

Example = function(){
	        return {
	            init : function(){
	               var layout = new Ext.BorderLayout(document.getElementById('contentpanel'), {
	                    west: {
	                        split:false,
	                        initialSize: 200,
	                        collapsible: false
	                    },
	                    east: {
	                        autoScroll: true
	                    }
	                });
	                layout.beginUpdate();
	                layout.add('west', new Ext.ContentPanel('nav'));
	                layout.add('east', new Ext.ContentPanel('contentpanel'));
	                layout.endUpdate();
	           }
	     }

	}();
	Ext.EventManager.onDocumentReady(Example.init, Example, true);
What's wrong ????

I use jquery to create menubar form markup .

Thanks
Reply With Quote
  #2  
Old 03-02-2007, 04:47 PM
DefaultRe: Problem with a inner layout and toolbar

Quote:
Originally Posted by malotor
I have a toolbar in content panel. I's works perfectly but when I put a layout in the container give me a js error.

My html[...]

	    <script type="text/javascript" src="./yui-ext/yui-utilities.js"></script>
	    <script type="text/javascript" src="./yui-ext/ext-all.js"></script>
	    <script type="text/javascript" src="./yui-ext/ext-bridge-yui.js"></script>
[...]What's wrong ????
I'm not sure if this will resolve the issues, but...

Old way:

yui-utilities.js
ext-all.js
ext-bridge-yui.js

New way:

yui-utilities.js or jquery.js
ext-yui-adapter.js or ext-jquery-adapter.js
ext-all.js (or core)

Try this:

Fresh out of the ext-1.0-alpha2.zip I got the toolbar working in the layout. In the examples folder, I dropped the menu folder files into the layout folder, updated the header in complex.html, and made two <div> right after the <body>(one for the toolbar and one for the layout.) One more thing, after that I changed the document.body to document.getElementById('myDiv'), and other than that the rest of the js is unmodified.

<html>
<head>
  <title>Complex Layout</title>
	<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />

         <script type="text/javascript" src="../../yui-utilities.js"></script>     <script type="text/javascript" src="../../ext-yui-adapter.js"></script>     
    <script type="text/javascript" src="../../ext-all.js"></script>
    
    
    <script type="text/javascript" src="menus.js"></script>
    <link rel="stylesheet" type="text/css" href="menus.css" />
    
    <link rel="stylesheet" type="text/css" href="../examples.css" />
  
    
	<style type="text/css">
	body {font:normal 9pt verdana; margin:0;padding:0;border:0px none;overflow:hidden;}
	.x-layout-panel-north {
	    border:0px none;
	}
	#nav {
	}
	#autoTabs, #center1, #center2, #west {
	    padding:10px;
	}
	#north, #south{
	    font:normal 8pt arial, helvetica;
	    padding:4px;
	}
	.x-layout-panel-center p {
	    margin:5px;
	}
	#props-panel .x-grid-col-0{
	}
	#props-panel .x-grid-col-1{
	}
	</style>
	<script type="text/javascript">
	
	Example = function(){
	        var layout;
	        return {
	            init : function(){
	               layout = new Ext.BorderLayout(document.getElementById('myDiv'), {
	                    hideOnLayout: true,
	                    north: {
	                        split:false,
	                        initialSize: 32,
	                        titlebar: false
	                    },
	                    west: {
	                        split:true,
	                        initialSize: 200,
	                        minSize: 175,
	                        maxSize: 400,
	                        titlebar: true,
	                        collapsible: true,
                            animate: true
	                    },
	                    east: {
	                        split:true,
	                        initialSize: 202,
	                        minSize: 175,
	                        maxSize: 400,
	                        titlebar: true,
	                        collapsible: true,
                            animate: true
	                    },
	                    south: {
	                        split:true,
	                        initialSize: 100,
	                        minSize: 100,
	                        maxSize: 200,
	                        titlebar: true,
	                        collapsible: true,
                            animate: true
	                    },
	                    center: {
	                        titlebar: true,
	                        autoScroll:true,
                            closeOnTab: true
                        }
	                });

                    layout.beginUpdate();
	                layout.add('north', new Ext.ContentPanel('north', 'North'));
	                layout.add('south', new Ext.ContentPanel('south', {title: 'South', closable: true}));
	                layout.add('west', new Ext.ContentPanel('west', {title: 'West'}));
	                layout.add('east', new Ext.ContentPanel(Ext.id(), {autoCreate:true, title: 'Dynamic Tab', closable: true}));
	                layout.add('east', new Ext.ContentPanel('autoTabs', {title: 'Auto Tabs', closable: true}));
	                layout.add('center', new Ext.ContentPanel('center1', {title: 'Close Me', closable: true}));
	                layout.add('center', new Ext.ContentPanel('center2', {title: 'Center Panel', closable: false}));
	                layout.getRegion('center').showPanel('center1');
	                layout.getRegion('west').hide();
	                layout.endUpdate();
	           },
	           
	           toggleWest : function(link){
	                var west = layout.getRegion('west');
	                if(west.isVisible()){
	                    west.hide();
	                    link.innerHTML = 'Show West Region';
	                }else{
	                    west.show();
	                    link.innerHTML = 'Hide West Region';
	                }
	           }
	            
	     };
	       
	}();
	Ext.EventManager.onDocumentReady(Example.init, Example, true);
	
	</script>
</head>
<body>

    <div id="toolbar" style="height:32px;"></div>
    <div id="myDiv" style="position:relative;"></div>
    
<script type="text/javascript" src="../examples.js"></script>
<div id ="container">
  <div id="west" class="x-layout-inactive-content">
    

I'm the west panel, pleased to make your acquaintance.</p>
  </div>
  <div id="north" class="x-layout-inactive-content">
    

Hey, I'm the North panel dude!</p>
  </div>
  <div id="autoTabs" class="x-layout-inactive-content">
      The layout manager will automatically create and/or remove the TabPanel component when a region has more than one panel. Close one of my panels and you can see what I mean.
  </div>
  <div id="center2" class="x-layout-inactive-content">
        

Show West Region</p>
        

My closable attribute is set to false so you can't close me. The other center panels can be closed.</p>
        

The center panel automatically grows to fit the remaining space in the container that isn't taken up by the border regions.</p>
        <hr>
        

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna. Aliquam commodo ullamcorper erat. Nullam vel justo in neque porttitor laoreet. Aenean lacus dui, consequat eu, adipiscing eget, nonummy non, nisi. Morbi nunc est, dignissim non, ornare sed, luctus eu, massa. Vivamus eget quam. Vivamus tincidunt diam nec urna. Curabitur velit. Quisque dolor magna, ornare sed, elementum porta, luctus in, leo.</p>
  </div>
  <div id="center1" class="x-layout-inactive-content">
        

Done reading me? Close me by clicking the X in the top right corner.</p>
        

Vestibulum semper. Nullam non odio. Aliquam quam. Mauris eu lectus non nunc auctor ullamcorper. Sed tincidunt molestie enim. Phasellus lobortis justo sit amet quam. Duis nulla erat, varius a, cursus in, tempor sollicitudin, mauris. Aliquam mi velit, consectetuer mattis, consequat tristique, pulvinar ac, nisl. Aliquam mattis vehicula elit. Proin quis leo sed tellus scelerisque molestie. Quisque luctus. Integer mattis. Donec id augue sed leo aliquam egestas. Quisque in sem. Donec dictum enim in dolor. Praesent non erat. Nulla ultrices vestibulum quam.</p>
  </div>
  <div id="props-panel" class="x-layout-inactive-content" style="width:200px;height:200px;overflow:hidden;">
  </div>
  <div id="south" class="x-layout-inactive-content">
    south - generally for informational stuff, also could be for status bar
  </div>
</div>

</body>
</html>
Reply With Quote
  #3  
Old 03-07-2007, 12:01 PM
Default

It works fine!!! It's could be a temporality solución for the problem.


Thanks
Reply With Quote
  #4  
Old 03-07-2007, 12:58 PM
Default

I have another problem :P. When a put a header the layout slice down and partialy hide the south region.

Take a look in http://www.harpra.com/yui/
Reply With Quote
  #5  
Old 03-07-2007, 01:21 PM
Default

I forgot login an password.

User:demo
pass:demo
Reply With Quote
  #6  
Old 03-07-2007, 04:30 PM
Default

Quote:
Originally Posted by malotor
Take a look in http://www.harpra.com/yui/
I tried to take a look but in Safari the page is showing up as blank.

...ok, it shows up in FF2
Reply With Quote
  #7  
Old 03-07-2007, 04:52 PM
Default

the login "demo" doesn't work. I took a look at the code I posted and I see the problem too. The bottom of the page is offset by the height of the first div. I am still getting aquatinted with Ext docs and couldn't tell you offhand. If you specify the height of the layout div it will work, but that way doesn't give you the option of having a vertical expanding design. I think it has to be specified in the js not the style, because on load layout manager measures the window and adjusts. Anyways, I will look for the solution but it might take me a while. I've already looked in layout manager and tried a couple different things to see if I could get it to readjust the size different, but no use, I can't tell yet exactly where it's doing the math. Maybe someone else knows?
Reply With Quote
  #8  
Old 03-07-2007, 06:04 PM
Default

Look at my response here and see if it helps with your layout:

http://www.yui-ext.com/forum/viewtopic.php?t=3572

You may want to consider rendering the layout to the document.body and including the toolbar in the north panel instead of having it outside the layout. I haven't seen your page though, so I'm not sure if there are any other issues.

Brian
__________________
Brian Moeskau
FAQ / Tutorials / User Extensions / Enhanced Forum Search
Reply With Quote
  #9  
Old 03-07-2007, 07:18 PM
Default

Thanks for your quick reply Brian. I think your suggestion is the fail-safe route, although I can see a reason to have the tool bar separately, for example: if a client wanted their website with an always-present top-of-the-page toolbar and a collapsable north region.

I am looking for the way to change some math in js that calculates the layout size, such as: get screen height -32px. Maybe there is something for this already? Another way: have a listener on monitor resize get window height -32px and then set the style of the element layout div with the new value.
Reply With Quote
  #10  
Old 03-09-2007, 09:18 AM
Default

I 'm solving problem and now show a blank page. I found a problems with DOCTYPE. When I use a DOCTYPE de panels collapse . If I remove the DOCTYPE and the page work.

Reply With Quote
【评估多目标跟踪方法】9个高度敏捷目标在编队中的轨迹和测量研究(Matlab代码实现)内容概要:本文围绕“评估多目标跟踪方法”,重点研究9个高度敏捷目标在编队飞行中的轨迹生成与测量过程,并提供完整的Matlab代码实现。文中详细模拟了目标的动态行为、运动约束及编队结构,通过仿真获取目标的状态信息与观测数据,用于验证和比较不同多目标跟踪算法的性能。研究内容涵盖轨迹建模、噪声处理、传感器测量模拟以及数据可视化等关键技术环节,旨在为雷达、无人机编队、自动驾驶等领域的多目标跟踪系统提供可复现的测试基准。; 适合人群:具备一定Matlab编程基础,从事控制工程、自动化、航空航天、智能交通或人工智能等相关领域的研究生、科研人员及工程技术人员。; 使用场景及目标:①用于多目标跟踪算法(如卡尔曼滤波、粒子滤波、GM-CPHD等)的性能评估与对比实验;②作为无人机编队、空中交通监控等应用场景下的轨迹仿真与传感器数据分析的教学与研究平台;③支持对高度机动目标在复杂编队下的可观测性与跟踪精度进行深入分析。; 阅读建议:建议读者结合提供的Matlab代码进行实践操作,重点关注轨迹生成逻辑与测量模型构建部分,可通过修改目标数量、运动参数或噪声水平来拓展实验场景,进一步提升对多目标跟踪系统设计与评估的理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值