首页 > 其他分享 >ExtJS中layout的12种布局风格

ExtJS中layout的12种布局风格

时间:2024-07-12 19:55:06浏览次数:8  
标签:12 layout title items width Ext html ExtJS

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}
]
复制代码

标签:12,layout,title,items,width,Ext,html,ExtJS
From: https://www.cnblogs.com/joe-tang/p/7144847.html

相关文章

  • extjs中treepanel例子
    :TreePanel继承自Panel,在ExtJS中使用树控件含有丰富的属性和方法实现复杂的功能。其中Ext.tree.TreeNode代表一个树节点,比较常用的属性包括text、id、icon、checked等、异步树Ext.tree.AsyncTreeNode、树加载器Ext.tree.TreeLoader。下面介绍几个extjs中treepanel例子一、TreePan......
  • Extjs xtype 一览表
    ExtJs xtype一览基本组件:xtypeClass描述buttonExt.Button按钮splitbuttonExt.SplitButton带下拉菜单的按钮cycleExt.CycleButton带下拉选项菜单的按钮buttongroupExt.ButtonGroup编组按钮(Since3.0)slider......
  • AI预测福彩3D采取888=3策略+和值012路或胆码测试7月12日新模型预测第32弹
             今天咱们继续验证新模型的8码定位=3,重点是预测8码定位=3+和值012+胆码。有些朋友看到我最近几篇文章没有给大家提供缩水后的预测详情,在这里解释下:其实我每篇文章中既有8码定位,也有和值012路,也有胆码排序,这些条件如果命中的话,其实大家完全可以自行使用一些免......
  • AI预测体彩排3采取888=3策略+和值012路或胆码测试7月12日升级新模型预测第27弹
            根据前面的预测效果,我对模型进行了重新优化,因为前面的模型效果不是很好。熟悉我的彩友比较清楚,我之前的主要精力是对福彩3D进行各种模型的开发和预测,排三的预测也就是最近1个月才开始搞的。3D的预测,经过对模型的多次修改和完善,最新的模型命中率有了大幅提高,大......
  • Extjs中的success和failure
    转载:http://blog.csdn.net/gangwazi0525/article/details/7314581 1.Ext.form.Action.Submit的配置选项success、failure根据返回json中success属性判断的,如果success为true,则success,false则failure,如果无json中无success属性,failure,故要提示操作是否成功,必须要返回success......
  • 搞懂清结算,只需要记住“123457”
    搞懂清结算其实总结起来就是1234567七个数字。怎么理解?我们来看看分享。前几天看了一篇万字长文,深度解析了支付机构的清结算账务处理原理。总结起来就是“1张图、2条线、3在途、4段数、5账户、7环节”,6去那了,大家可以找找,其中 1张图就是这样一张极简图,基本阐述了整个清结......
  • 2024-07-12 vue项目中 运行 npm run build 或 yarn build 打包 没有生成 xx.es.js 文
    我在写一个ui组件库,在打包时发现dist文件夹里没有生成我想要的xx.es.js文件,我查看了我的vue项目中的vue.config.js文件,发现build.lib没有指定输出的文件名解决方案:配置项目中的vue.config.js文件,参考我的......
  • Linux捣鼓记录:debian12解决用户无法执行sudo,提示不是 sudoers 文件
    问题:dalong@debian:~$sudoaptupdate[sudo]dalong的密码:dalong不是sudoers文件。当你尝试使用sudo命令并收到"dalong不是sudoers文件"的错误信息时,这意味着用户dalong没有被配置为可以使用sudo命令。在Debian和其他基于Debian的系统中,sudo的权限是由......
  • Visual Studio 2013俄语环境基石:‘mfc120rus.dll’解析与丢失修复全案
    mfc120rus.dll是一个动态链接库(DLL)文件,与MicrosoftFoundationClasses(MFC)相关。MFC是一个广泛使用的C++类库,用于简化Windows应用程序的开发。mfc120rus.dll特别地,是MFC库的俄语版本,用于支持俄语字符集和语言环境,它是MFC12.0版本的一部分,常用于VisualStudio2013中编译的......
  • vue3前端项目结构解析(2024-07-12)
    .├──build#打包脚本相关│  ├──config#配置文件│  ├──generate#生成器│  ├──script#脚本│  └──vite#vite配置├──mock#mock文件夹├──public#公共静态资源目录├──src#主目录│  ├──api#接口......