---
title: "extjs布局"
author: "sdcharles"
date: "2011-03-30T11:59:21Z"
tags: []
categories: ["Web前端"]
slug: "extjs"
draft: false
lastmod: "2011-03-30T11:59:21Z"
id: 980315
url: "https://sdcharles.iteye.com/blog/980315"
---

以下引用自[http://blog.csdn.net/nikyxxx/archive/2010/01/27/5261994.aspx](http://blog.csdn.net/nikyxxx/archive/2010/01/27/5261994.aspx)感谢原作者

 

01. /*
02. * Ext JS Library 2.2
03. * Copyright(c) 2006-2008, Ext JS, LLC.
04. * licensing@extjs.com
05. \*
06. * 翻译:廖瀚卿 yourgame@163.com
07. \*
08. * http://extjs.com/license
09. \*/
10. //
11. // This is the main layout definition.
12. // 这里是一个主要布局的定义.
13. //
14. Ext.onReady(function(){
15. Ext.QuickTips.init(); //初始提示tip
16. // This is an inner body element within the Details panel created to provide a "slide in" effect
17. // on the panel body without affecting the body's box itself.  This element is created on
18. // initial use and cached in this var for subsequent access.
19. // 这是一个位于详细资料面板的内部的主体元素 提供从面板外部滑入面板内部的效果,这个元素当初始化时被创建同时存储这个变量中用于缓存后来的
20. var detailEl;
21. // This is the main content center region that will contain each example layout panel.
22. // 这个一个主要包含每个示例布局的中间区域的面板
23. // It will be implemented as a CardLayout since it will contain multiple panels with
24. // only one being visible at any given time.
25. // 它应用于卡片布局后将包含多个面板,任何时候只有一个面板可以呈现.
26. var contentPanel = {
27. id: 'content-panel',
28. region: 'center', // this is what makes this panel into a region within the containing layout
29. layout: 'card',
30. margins: '2 5 5 0',
31. activeItem: 0,
32. border: false,
33. items: [
34. // 来自于 basic.js:
35. start, absolute, accordion, anchor, border, cardTabs, cardWizard, column, fit, form, table,
36. // 来自于 custom.js:
37. rowLayout, centerLayout,
38. // 来自于 combination.js: \[combination:为组合的意思]
39. absoluteForm, tabsNestedLayouts
40. ]
41. };
42. // Go ahead and create the TreePanel now so that we can use it below
43. // 先创建一个书面板,以备我们接下来使用
44. var treePanel = new Ext.tree.TreePanel({
45. id: 'tree-panel',
46. title: 'Sample Layouts',
47. region:'north', //北边
48. split: true, //可以调节大小
49. height: 300, //默认高度为300px
50. minSize: 150, //最小高度为150px
51. autoScroll: true,//允许滚动条
52. // tree-specific configs:
53. // 树控件的特有的配置选项
54. rootVisible: false,//隐藏根结点
55. lines: false,
56. singleExpand: true,//同时只能打开一个树,当打开其中任何一个树时,将会关闭其他已经打开的树目录
57. useArrows: true,//树形目录使用visit中树目录显示效果(三角形代替+号)
58. loader: new Ext.tree.TreeLoader({
59. dataUrl:'tree-data.json'//树目录数据加载为本地json数据文件
60. }),
61. root: new Ext.tree.AsyncTreeNode()
62. });
63. // Assign the changeLayout function to be called on tree node click.
64. // 指定一个当树节点被单击后更改布局的函数.
65. treePanel.on('click', function(n){  //n为节点对象
66. var sn = this.selModel.selNode || {}; // selNode is null on initial selection 如果树的选择模型为空则初始化它
67. if(n.leaf && n.id != sn.id){  // ignore clicks on folders and currently selected node
68. // 忽略文件夹的单击以及当前已经选择节点的多次单击操作
69. Ext.getCmp('content-panel').layout.setActiveItem(n.id + '-panel');
70. //获得内容面板.设置当前获得的面板项为(json数据中的id名字(如:"id:'absolute'")加上 '-panel' 组成 'absolute-panel'
71. //这样来使面板处于活动状态(即显示)
72. if(!detailEl){//处理详细资料的显示元素,当这个