ExtJS中layout的12种布局风格

news/2024/11/15 9:52:34/文章来源:https://www.cnblogs.com/joe-tang/p/7144847.html

extjs的容器组件都可以设置它的显示风格,它的有效值有 absolute, accordion, anchor, border, card, column, fit, form and table.  一共9种。

另外几种见:  http://www.sencha.com/deploy/dev/examples/layout-browser/layout-browser.html  里面有详细的例子。

 

·  absolute 顾名思义,在容器内部,根据指定的坐标定位显示 

This is a simple layout style that allows you to position items within a container using CSS-style absolute positioning via XY coordinates.

Sample Config:

复制代码
layout: 'absolute',
items:[{title: 'Panel 1',x: 50,y: 50,html: 'Positioned at x:50, y:50'
}]
复制代码

 

· accordion 这个是最容易记的,手风琴效果

Displays one panel at a time in a stacked layout. No special config properties are required other than the layout — all panels added to the container will be converted to accordion panels.

复制代码
<!DOCTYPE html>
<html><head><title>hello-extjs</title><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="this is my page"><meta http-equiv="content-type" content="text/html; charset=UTF-8"><!--<link rel="stylesheet" type="text/css" href="./styles.css">--><!-- 引入extjs样式文件 --><link rel="stylesheet" type="text/css" href="ext-3.4.1/resources/css/ext-all.css" /><!-- 引入extjs库文件,底层驱动 --><script type="text/javascript" src="ext-3.4.1/adapter/ext/ext-base.js"></script><!-- 引入extjs-all --><script type="text/javascript" src="ext-3.4.1/ext-all.js"></script><!-- <script type="text/javascript" src="extjs/ext-lang-zh_CN.js" charset="utf-8"></script> --><script type="text/javascript">Ext.onReady(function(){  var panel=new Ext.Panel(//Ext.formPanel 就是Panel中用了form布局  {  renderTo:'paneldiv',  title:'容器组件',  layout:'accordion',         width:500,  height:200,  layoutConfig:{animate:false},  items:[  {title:'元素1',html:''},  {title:'元素2',html:''},  {title:'元素3',html:''},  {title:'元素4',html:''}  ]  }  );  });  </script></head><body>This is my HTML page. <br><div id="paneldiv"></div></body>
</html>
复制代码

· anchor 这个效果具体还不知道有什么用,就是知道注意一下  
1.容器内的组件要么指定宽度,要么在anchor中同时指定高/宽,  

2.anchor值通常只能为负值(指非百分比值),正值没有意义,  
3.anchor必须为字符串值

Provides anchoring of contained items to the container's edges. This type of layout is most commonly seen within FormPanels (or any container with a FormLayout) where fields are sized relative to the container without hard-coding their dimensions.

In this example, panels are anchored for example purposes so that you can easily see the effect. If you resize the browser window, the anchored panels will automatically resize to maintain the same relative dimensions.

复制代码
<!DOCTYPE html>
<html><head><title>hello-extjs</title><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="this is my page"><meta http-equiv="content-type" content="text/html; charset=UTF-8"><!--<link rel="stylesheet" type="text/css" href="./styles.css">--><!-- 引入extjs样式文件 --><link rel="stylesheet" type="text/css" href="ext-3.4.1/resources/css/ext-all.css" /><!-- 引入extjs库文件,底层驱动 --><script type="text/javascript" src="ext-3.4.1/adapter/ext/ext-base.js"></script><!-- 引入extjs-all --><script type="text/javascript" src="ext-3.4.1/ext-all.js"></script><!-- <script type="text/javascript" src="extjs/ext-lang-zh_CN.js" charset="utf-8"></script> --><script type="text/javascript">Ext.onReady(function() {   var panel1 = new Ext.Panel({   title: "panel1",  height: 100,   anchor: '-50',    html: "高度等于100,宽度=容器宽度-50"    });var panel2 = new Ext.Panel({title: "panel2",height: 100,anchor: '50%',   html: "高度等于100,宽度=容器宽度的50%"   });      var panel3 = new Ext.Panel({   title: "panel3",   anchor: '-10, -250',   html: "宽度=容器宽度-10,高度=容器宽度-250"   });       var win = new Ext.Window({   title: "Anchor Layout",   height: 400, width: 400,   plain: true,                       layout: 'anchor',   items: [panel1, panel2,panel3]               });   win.show();   }); </script></head><body>This is my HTML page. <br><div id="paneldiv"></div></body>
</html>
复制代码

 

 

· border 将容器分为五个区域:east,south,west,north,center

This Layout Browser page is already a border layout, and this example shows a separate border layout nested within a region of the page's border layout. Border layouts can be nested with just about any level of complexity that you might need.

Every border layout must at least have a center region. All other regions are optional.

Sample Config:

复制代码
layout:'border',
defaults: {collapsible: true,split: true,bodyStyle: 'padding:15px'
},
items: [{title: 'Footer',region: 'south',height: 150,minSize: 75,maxSize: 250,cmargins: '5 0 0 0'
},{title: 'Navigation',region:'west',margins: '5 0 0 0',cmargins: '5 5 0 0',width: 175,minSize: 100,maxSize: 250
},{title: 'Main Content',collapsible: false,region:'center',margins: '5 0 0 0'
}]
复制代码

 

 

· card (TabPanel)

复制代码
<!DOCTYPE html>
<html><head><title>hello-extjs</title><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="this is my page"><meta http-equiv="content-type" content="text/html; charset=UTF-8"><!--<link rel="stylesheet" type="text/css" href="./styles.css">--><!-- 引入extjs样式文件 --><link rel="stylesheet" type="text/css" href="ext-3.4.1/resources/css/ext-all.css" /><!-- 引入extjs库文件,底层驱动 --><script type="text/javascript" src="ext-3.4.1/adapter/ext/ext-base.js"></script><!-- 引入extjs-all --><script type="text/javascript" src="ext-3.4.1/ext-all.js"></script><!-- <script type="text/javascript" src="extjs/ext-lang-zh_CN.js" charset="utf-8"></script> --><script type="text/javascript">Ext.onReady(function() {        var button = Ext.get('show-btn');   var win;button.on('click', function() {   //创建TabPanel   var tabs = new Ext.TabPanel({   region: 'center', //border 布局,将页面分成东,南,西,北,中五部分,这里表示TabPanel放在中间   margins: '3 3 3 0',   activeTab: 0,   defaults: {   autoScroll: true   },  items: [{   title: 'Bogus Tab',   html: "第一个Tab的内容."   }, {   title: 'Another Tab',   html: "我是另一个Tab"   }, {   title: 'Closable Tab',   html: "这是一个可以关闭的Tab",   closable: true   }]   });   //定义一个Panel   var nav = new Ext.Panel({   title: 'Navigation',   region: 'west', //放在西边,即左侧   split: true,   width: 200,   collapsible: true, //允许伸缩   margins: '3 0 3 3',   cmargins: '3 3 3 3'   });   //如果窗口第一次被打开时才创建   if (!win) {   win = new Ext.Window({   title: 'Layout Window',   closable: true,   width: 600,   height: 350,   border : false,   plain: true,   layout: 'border',   closeAction:'hide',   items: [nav, tabs]//把上面创建的panel和TabPanel放在window中,并采用border方式布局   });   }   win.show(button);   });   });  </script></head><body>This is my HTML page. <br><button id="show-btn">button</button></body>
</html>
复制代码

 

 · card (Wizard)

You can use a Card layout to create your own custom wizard-style screen. The layout is a standard CardLayout with a Toolbar at the bottom, and the developer must supply the navigation function that implements the wizard's business logic (see the code in basic.js for details).

Sample Config:

复制代码
layout:'card',
activeItem: 0, // index or id
bbar: ['->', {id: 'card-prev',text: '&laquo; Previous'
},{id: 'card-next',text: 'Next &raquo;'
}],
items: [{id: 'card-0',html: 'Step 1'
},{id: 'card-1',html: 'Step 2'
},{id: 'card-2',html: 'Step 3'
}]
复制代码

 

 
· column 把整个容器看成一列,然后向容器放入子元素时

This is a useful layout style when you need multiple columns that can have varying content height. Any fixed-width column widths are calculated first, then any percentage-width columns specified using the columnWidth config will be calculated based on remaining container width. Percentages should add up to 1 (100%) in order to fill the container.

Sample Config:

复制代码
layout:'column',
items: [{title: 'Width = 25%',columnWidth: .25,html: 'Content'
},{title: 'Width = 75%',columnWidth: .75,html: 'Content'
},{title: 'Width = 250px',width: 250,html: 'Content'
}]
复制代码

 

· fit 一个子元素将充满整个容器(如果多个子元素则只有一个元素充满整个容器)

A very simple layout that simply fills the container with a single panel. This is usually the best default layout choice when you have no other specific layout requirements.

Sample Config:

layout:'fit',
items: {title: 'Fit Panel',html: 'Content',border: false
}

 

·  form 是一种专门用于管理表单中输入字段的布局

复制代码
<!DOCTYPE html>
<html><head><title>hello-extjs</title><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="this is my page"><meta http-equiv="content-type" content="text/html; charset=UTF-8"><!--<link rel="stylesheet" type="text/css" href="./styles.css">--><!-- 引入extjs样式文件 --><link rel="stylesheet" type="text/css" href="ext-3.4.1/resources/css/ext-all.css" /><!-- 引入extjs库文件,底层驱动 --><script type="text/javascript" src="ext-3.4.1/adapter/ext/ext-base.js"></script><!-- 引入extjs-all --><script type="text/javascript" src="ext-3.4.1/ext-all.js"></script><!-- <script type="text/javascript" src="extjs/ext-lang-zh_CN.js" charset="utf-8"></script> --><script type="text/javascript">Ext.onReady(function() {    var win = new Ext.Window({   title: "form Layout",   height: 150,   width: 230,   plain: true,    bodyStyle: 'padding:15px',    items:    {    xtype: "form",   labelWidth: 30,   defaultType: "textfield",    frame:true,   items:    [   {    fieldLabel:"姓名",   name:"username",   allowBlank:false    },   {    fieldLabel:"呢称",   name:"nickname"    },   {    fieldLabel: "生日",   xtype:'datefield',   name: "birthday",    width:127    }   ]   }   });   win.show();    });   </script></head><body>This is my HTML page. <br></body>
</html>
复制代码

 · table 按照普通表格的方法布局子元素,用layoutConfig:{columns:3},//将父容器分成3列

复制代码
<!DOCTYPE html>
<html><head><title>hello-extjs</title><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="this is my page"><meta http-equiv="content-type" content="text/html; charset=UTF-8"><!--<link rel="stylesheet" type="text/css" href="./styles.css">--><!-- 引入extjs样式文件 --><link rel="stylesheet" type="text/css" href="ext-3.4.1/resources/css/ext-all.css" /><!-- 引入extjs库文件,底层驱动 --><script type="text/javascript" src="ext-3.4.1/adapter/ext/ext-base.js"></script><!-- 引入extjs-all --><script type="text/javascript" src="ext-3.4.1/ext-all.js"></script><!-- <script type="text/javascript" src="extjs/ext-lang-zh_CN.js" charset="utf-8"></script> --><script type="text/javascript">Ext.onReady(function(){    var panel=new Ext.Panel(   {   renderTo:'paneldiv',   title:'容器组件',   layout:'table',          width:500,   height:200,   layoutConfig:{columns:3},//将父容器分成3列   items:[   {title:'元素1',html:'ssssssssss',rowspan:2,height:100},   {title:'元素2',html:'dfffsddsdfsdf',colspan:2},   {title:'元素3',html:'sdfsdfsdf'},   {title:'元素4',html:''}   ]   });   }); </script></head><body>This is my HTML page. <br><div id="paneldiv"><div></body>
</html>
复制代码

VBox

A layout that allows for the vertical and horizontal stretching of child items, much like the container layout with size management.

Sample Config:

复制代码
layout: {type: 'vbox'align : 'stretch',pack  : 'start',
},
items: [{html:'panel 1', flex:1},{html:'panel 2', height:150},{html:'panel 3', flex:2}
]
复制代码

 

HBox

A layout that allows for the vertical and horizontal stretching of child items, much like the column layout but can stretch items vertically.

Sample Config:

复制代码
layout: {type: 'hbox',pack: 'start',align: 'stretch'
},
items: [{html:'panel 1', flex:1},{html:'panel 2', width:150},{html:'panel 3', flex:2}
]
复制代码

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/742672.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

extjs中treepanel例子

:TreePanel继承自Panel,在ExtJS中使用树控件含有丰富的属性和方法实现复杂的功能。其中Ext.tree.TreeNode代表一个树节点,比较常用的属性包括text、id、icon、checked等、异步树Ext.tree.AsyncTreeNode、树加载器Ext.tree.TreeLoader。下面介绍几个extjs中treepanel例子一、…

全球单体容量最大漂浮式风电平台“明阳天成号”正式亮相

7月12日,全球单体容量最大的16.6MW漂浮式风电平台“明阳天成号”启航仪式在中船黄埔文冲造船厂举办,中山市委书记、市人大常委会主任郭文海主礼启航仪式。“明阳天成号”于7月3日完成吊装,经过各项调试准备工作后正式亮相,并将择日拖航至广东阳江海域。据测算,“明阳天成号…

从程序员的角度来看为什么我们需要工作流

每一个程序员,在接触到工作流的时候,都会有这么一个疑问——我用一般的方法可以实现,为什么还要用工作流?我曾经也问过这个问题,不过现在稍微有点明白了。别着急要答案,看过下面的例子,或许你也就明白一些了。这是一个简单的业务——订货流程:客户提交采购订单 业务员执…

003_python3 解释器 注释 运算符

Python3 解释器 1.Linux设置环境变量 $ PATH=$PATH:/usr/local/python3/bin/python3 # 设置环境变量 2.交互式编程 $ python # 启动Python解释器 3.脚本式编程 Windows中写入脚本xx.py文件,执行 python xx.py # cmd 当中直接执行 Linux中文件顶部写入 #! /usr/bin/env py…

2024暑假集训测试4

前言比赛链接这次和高中一起打的,排名一次比一次低了,差点出前一半了…… 主要是 T1 \(dijkstra\) 唐氏复杂度打假了,T2 挂分,T3 没想出来压位,T4 题都没看。 T1 最短路原题:luogu P2966 [USACO09DEC] Cow Toll Paths G。本题考察对 \(Floyed\) 的理解,\(Floyed\) 数组在…

Bootstrap图片样式使用方法

在Bootstrap中自带了几种图片样式,能够让你很快地对其进行使用,这几种样式使用起来相当简单,让我们一起来看看怎么快速调用Bootstrap图片样式。Bootstrap图片圆角样式 在现今的网站建设中,由于扁平化设计的趋势,我们经常会用用到一些CSS3的特性,例如圆角、渐变、阴影等。…

SQL中“ ` ”的作用是什么?

避免和 mysql 的本身的关键字 冲突 所以 用这个符号括起来 虽然有时候不影响 查询 但是最好是要 加上的

《三体开源传》第二章 科技图谱

科技树?汪淼大脑中突然闪过这个概念。哦,不对,应该是科技图谱,图中交织的连线的复杂度已经远远超过树形结构所能描述的单一路径依赖关系,甚至还出现了环形结构和复杂的社群聚集。科技树:科技树是一种结构图,它将技术按照发展顺序排列成树状,展示从基础技术到高级应用的…

Graphrag: Hello World !

这两天抽空玩了一把 Graphrag, 记录一下测试步骤。先决条件: Python 3.10-3.12备注: 以下所有脚本都在 PowerShell环境下运行 1. 首先安装一下 graphrag python包 pip install --trusted-host https://mirrors.huaweicloud.com -i https://mirrors.huaweicloud.com/repository…

R语言软件套保期限GARCH、VAR、OLS回归模型对沪深300金融数据可视化分析

全文链接:https://tecdat.cn/?p=34670 原文出处:拓端数据部落公众号 金融市场的波动性一直是投资者和决策者关注的焦点之一。为了应对市场波动的风险,套保成为了一种重要的金融手段。在这个背景下,使用R语言软件中的GARCH VAR模型对沪深300金融数据进行分析,可以帮助我们更…

【视频讲解】Python比赛LightGBM、XGBoost+GPU和CatBoost预测学生在游戏学习过程表现|数据代码分享

全文链接:https://tecdat.cn/?p=36990原文出处:拓端数据部落公众号分析师:Qi Zhang背景基于游戏进行学习能让学校变得有趣,这种教育方法能让学生在游戏中学习,使其变得有趣和充满活力。尽管基于游戏的学习正在越来越多的教育环境中使用,但能用应用数据科学和学习分析原理…