dhtmlxLayout应用方法
- 格式:docx
- 大小:69.43 KB
- 文档页数:14
图纸系统-dhtmlxtree使用步骤、1.搭建环境:将解压缩后的dhtmlxtree文件拷贝到webroot下面;2.用sevlet动态生成xml;(见:DHtmlServletForDirectory_Tzml.java)3.web.xml 配置<servlet><servlet-name>DHtmlServletForDirectory_Tzml</servlet-name><servlet-class>com.hirisun.tzgl.basic.DHtmlServletForDirectory_Tzml</servlet-class></servlet><servlet-mapping><servlet-name>DHtmlServletForDirectory_Tzml</servlet-name><url-pattern>/DHtmlServletForDirectory_Tzml</url-pattern></servlet-mapping>4.Jsp页面;(见:tzgl_dztzjy_tzml.jsp)a. 引入dhtmlxtree树的css和js<link rel="STYLESHEET" type="text/css"href="dhtmlxTree/dhtmlxTree/codebase/dhtmlxtree.css"><script src="dhtmlxTree/dhtmlxTree/sources/dhtmlxcommon.js"></script><script src="dhtmlxTree/dhtmlxTree/sources/dhtmlxtree.js"></script>b.生成树的核心代码<div id="tree_div" style="width:100%;height:100%"></div><script type="text/javascript">var dzdata = "";document.getElementById("tree_div").innerHTML="";//创建dhtmlXTreeObject对象,参数:"treebox_user"--显示树的div的id,“-1”--树的根ID catalogtree=new dhtmlXTreeObject("tree_div","100%","100%","0");//设置图片路径catalogtree.setImagePath("<%=path%>/dhtmlxTree/dhtmlxTree/codebase/imgs/csh_bluebo oks/");//设置树可以复选catalogtree.enableCheckBoxes(1);//允许三种状态的复选框(全选、不选、部分选中)catalogtree.enableThreeStateCheckboxes(true);//设置节点展开/合拢事件//catalogtree.setOnOpenHandler(itemOnOpen);//设置鼠标点击事件//catalogtree.setOnClickHandler(itemOnClick);//动态装载子结点用到的链接,需要返回一个xml文件,会自动传递父结点IDcatalogtree.setXMLAutoLoading("<%=path%>/DHtmlServletForDirectory_Tzml?jyid=<%=jyid %>");//初始化加载树用到的请求链接,注:此时传递的id一定要与创建树对象的根id一致。
1、Layout: (2)1.1常用的布局样式: (2)1.2基本用法: (2)1.2.1、Layout_init_object(基本显示方式) (2)1.2.2、Layout_init_window(将其放入一个windows中) (2)1.2.3、Layout_init_fullscreen(全屏幕显示) (2)1.2.4、Layout_init_layout(在layout中套入layout完成复杂样式) (3)1.2.5、Layout_init_api(layout的部分api参数) (3)1.2.6、Layout_init_skinning(更换layout样式) (3)1.2.7、Layout_init_views(更换layout中的内容) (4)1.2.8、Layout_conf_access(修改layout的标题) (4)1.2.9、Layout_conf_id_index(根据索引得到id、根据id得到相应的索引值) (4)1.2.10、Layout_conf_iterator(为layout写入名字) (5)1.2.11、Layout_conf_autosize(没看明白) (5)1.2.12、Layout_conf_panels(通过button方法修改layout属性) (7)1.2.13、Layout_conf_attach_object(layout的项目中加入div并显示其中内容) .91.2.14、Layout_conf_attach_url(给项目加上url地址,可直接嵌入页面) (9)1.2.15、Layout_conf_effects(没看出来有效果) (10)1.2.16、Layout_conf_collapsed(给项目折叠时加上标题或者图片) (10)1.2.17、Layout_conf_header_footer(给layout加上header和footer) (10)1.2.18、Layout_global_menu(给layout的上面加上工具) (10)1.2.19、Layout_ components_XX(给layout加上各种的组件) (11)1.2.20、Layout_events_XXX(监听layout上的事件) (12)2、Accordion (14)2.1基本用法 (14)2.1.1、Accordion_init_object (14)2.1.2、Accordion_init_window (14)2.1.3、Accordion_init_layout (14)DHX总结记录:1、Layout:1.1常用的布局样式:1.2基本用法:1.2.1、Layout_init_object(基本显示方式)dhxLayout = new dhtmlXLayoutObject("parentId", "4I");在页面上显示1.2.2、Layout_init_window(将其放入一个windows中)var windows =new dhtmlXWindows();windows.enableAutoViewport(false);//控制窗口是否自动显示在页面上windows.attachViewportTo("winVP")//控制窗口显示在某个特定的div层中var window_3 = windows.createWindow('window_3',0,0,300,400);var layout_1 = window_3.attachLayout('3E');1.2.3、Layout_init_fullscreen(全屏幕显示)function openLayout(){window.open("inc/fullscreen_inner.html");//打开指定的新页面}1.2.4、Layout_init_layout(在layout中套入layout完成复杂样式)dhxLayout = new dhtmlXLayoutObject("parentId", "3L");layout1 = new dhtmlXLayoutObject(dhxLayout.cells("b"), "2U");1.2.5、Layout_init_api(layout的部分api参数)var dhxLayoutData = {parent: "parentId",//所属div的idpattern: "4H",//基本样式cells: [{id: "a",text: "Navigation",//每个框的显示的名字width: 100,header: false,//框头隐藏fix_size: [true, null]}, {id: "b",text: "Advertisement",height: 100}, {id: "c",text: "Main Page"}, {id: "d",text: "Links",collapse: true //默认不打开是折叠式的}]};dhxLayout = new dhtmlXLayoutObject(dhxLayoutData);dhxLayout.cells("a").attachObject("objId");//a中加入objId中的内容1.2.6、Layout_init_skinning(更换layout样式)document.getElementById("tr_" + activeSkin).style.backgroundColor = "#FFFFFF";activeSkin = skin;doOnLoad();document.getElementById("tr_" + activeSkin).style.backgroundColor = "#CFCFCF";1.2.7、Layout_init_views(更换layout中的内容)<input type="button"value="Grid"onclick='dhxLayout.cells("a").view("def").setActive();'><input type="button"value="Tree"onclick='dhxLayout.cells("a").view("tree").setActive();'>//两个按钮触发更换的事件function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "3L");dhxGrid = dhxLayout.cells("a").attachGrid();dhxGrid.setImagePath("../../../dhtmlxGrid/codebase/imgs/");dhxGrid.loadXML("../common/grid.xml?etc="+ new Date().getTime());dhxTree = dhxLayout.cells("a").view("tree").attachTree();dhxTree.setImagePath("../../../dhtmlxTree/codebase/imgs/csh_vista/");dhxTree.loadXML("../common/tree.xml?etc="+ new Date().getTime()); }1.2.8、Layout_conf_access(修改layout的标题)dhxLayout = new dhtmlXLayoutObject("parentId", "3J");// 通过 cells修改dhxLayout.cells("a").setText("The Secret of Monkey Island");// 通过items 修改dhxLayout.items[1].setText("Monkey Island 2: LeChuck's Revenge");1.2.9、Layout_conf_id_index(根据索引得到id、根据id得到相应的索引值)Get ID by Index <select id="inds"></select><input type="button"value="Get ID"onclick="getId();"> //根据索引求idGet Index by ID <select id="ids"></select><input type="button"value="Get Index"onclick="getIndex();"> //根据id获得索引var dhxLayout, ids, inds;function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "5I");ids = document.getElementById("ids");inds = document.getElementById("inds");dhxLayout.forEachItem(function(item){ //遍历layout向id、ids 中加入数据ids.options.add(new Option(item.getId(), item.getId()));inds.options.add(new Option(item.getIndex(),item.getIndex()));});}function getId(){var ind = inds.options[inds.selectedIndex].value;alert(dhxLayout.getIdByIndex(ind));}function getIndex(){var id = ids.options[ids.selectedIndex].value;alert(dhxLayout.getIndexById(id));}1.2.10、Layout_conf_iterator(为layout写入名字)var names = new Array("Gothic 3 Forsaken Gods", "The Bard's Tale", "NFS Undercover", "The Punisher", "Diablo 2 Lord Of Destruction");var newNames = true;var j = 0;var dhxLayout;function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "5I");}function update(){//改名字的方法dhxLayout.forEachItem(function(item){item.setText(newNames ? names[j++] : item.getId());});newNames = !newNames;j = 0;}1.2.11、Layout_conf_autosize(没看明白)<div id="winVP"style="position: relative; height: 500px; border:#cecece 1px solid; margin: 10px;"></div><div id="srcDiv"style="position: relative; left: 20px; width:600px;"></div><div style="position: relative; margin-top: 20px; left: 20px; width: 600px;">Please, select the cells which will be autosized in the process of resizing</div><div id="viewDiv"style="position: relative; margin-top: 20px; left: 20px; width: 600px;">Autosize: HOR <select id="sel1"></select> VER <selectid="sel2"></select><input type="button"value="Apply"onclick="setAutoSize();"></div><script>var dhxWins,dhxLayout;var sel1 = document.getElementById("sel1");var sel2 = document.getElementById("sel2");function doOnLoad(){dhxWins = new dhtmlXWindows();dhxWins.enableAutoViewport(false);dhxWins.attachViewportTo("winVP");dhxWins.setImagePath("../../../dhtmlxWindows/codebase/imgs/");dhxWins.createWindow("w1", 20, 30, 600, 400);loadView("3L");var views = dhxLayout.listViews();var table = document.createElement("TABLE");document.getElementById("srcDiv").appendChild(table);var tbody = document.createElement("TBODY");table.appendChild(tbody);var tr1 = document.createElement("TR");tbody.appendChild(tr1);var tr2 = document.createElement("TR");tbody.appendChild(tr2);for(var q = 0; q < views.length; q++){var td1 = document.createElement("TD");var td2 = document.createElement("TD");td1.innerHTML = views[q];td2.innerHTML = "<img src='../common/imgs/" +String(views[q]).toLowerCase()+ ".bmp' style='height: 49px; width: 49px; cursor: pointer;' onclick='loadView(\"" + views[q] + "\");'>";tr1.appendChild(td1);tr2.appendChild(td2);}}function loadView(view){if(dhxLayout != null)dhxLayout.unload();dhxLayout = dhxWins.window("w1").attachLayout(view);//;var asData = dhxLayout.listAutoSizes();sel1.options.length = 0;var selected = 0;for(var q = 0; q < asData[2].length; q++){if(asData[2][q] == asData[0]){selected = q;}sel1.options.add(new Option(asData[2][q].replace(/;/g, ""), asData[2][q]));}sel1.selectedIndex = selected;sel2.options.length = 0;var selected = 0;for(var q = 0; q < asData[3].length; q++){if(asData[3][q] == asData[1]){selected = q;}sel2.options.add(new Option(asData[3][q].replace(/;/g, ""), asData[3][q]));}sel2.selectedIndex = selected;}function setAutoSize(){var sel1 = document.getElementById("sel1");var as1 = sel1.options[sel1.selectedIndex].value;var sel2 = document.getElementById("sel2");var as2 = sel2.options[sel2.selectedIndex].value;//;dhxLayout.setAutoSize(as1, as2);}</script>1.2.12、Layout_conf_panels(通过button方法修改layout属性)<script>var dhxLayout;var sel = document.getElementById("sel");function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "3L");dhxLayout.forEachItem(function(item){sel.options.add(new Option(item.getId(), item.getIndex()));});}function getInd(){//得到id属性var sel = document.getElementById("sel");var id = sel.options[sel.selectedIndex].value;return id;}function setText(){ //修改layout标题dhxLayout.items[getInd()].setText(document.getElementById("txt").valu e);}function isVisible(){//判断标题是否隐藏(隐藏返回false、活动返回true)alert(dhxLayout.items[getInd()].isHeaderVisible());}function hidePanel(){//隐藏layout标题dhxLayout.items[getInd()].hideHeader();}function showPanel(){//显示layout标题dhxLayout.items[getInd()].showHeader();}function expand(){//展开所选择的项目dhxLayout.items[getInd()].expand();}function collapse(){//折叠所选择的项目dhxLayout.items[getInd()].collapse();}function setWidth(){//在总的允许的范围内设置项目的宽dhxLayout.items[getInd()].setWidth(Number(document.getElementById("it em_w").value));}function setHeight(){//在总的允许的范围内设置项目的高dhxLayout.items[getInd()].setHeight(Number(document.getElementById("i tem_h").value));}function getWidth(){//得到项目的宽alert(dhxLayout.items[getInd()].getWidth());}function getHeight(){//得到项目的宽alert(dhxLayout.items[getInd()].getHeight());}function fixSize(){//固定项目的长和宽dhxLayout.items[getInd()].fixSize((宽是否固定true固定、false不固定),(长是否固定));}function progressOn(fullLayout){//给layout、项目,加上进度条(不知道有什么用)if(fullLayout){dhxLayout.progressOn();}else{dhxLayout.items[getInd()].progressOn();}}function progressOff(fullLayout){//给layout、项目,去掉进度条if(fullLayout){dhxLayout.progressOff();}else{dhxLayout.items[getInd()].progressOff();}}</script>1.2.13、Layout_conf_attach_object(layout的项目中加入div并显示其中内容)<div id="parentId"style="position: relative; top: 20px; left: 20px; width: 600px; height: 400px; aborder: #B5CDE4 1px solid;"></div><div id="objId"style="width: 100%; height: 100%; overflow: auto; display: none; font-family: Tahoma; font-size: 11px;"><div style="margin: 3px 5px 3px 5px;">The film ends with Arthur and Guinevere's marriage. Merlin then proclaims him to be their king. King Arthur and his remaining knights promise to lead the Britons, now united after the Romans leave, against future invaders. The last scene shows Lancelot, Dagonet and Tristan roaming the lands freely as reincarnated horses as told in a legend by Lancelot's father.</div></div><script>var dhxLayout;function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "3U");dhxLayout.cells("a").setHeight(200);dhxLayout.cells("a").attachObject("objId");}1.2.14、Layout_conf_attach_url(给项目加上url地址,可直接嵌入页面)dhxLayout.cells("a").attachURL("/");1.2.15、Layout_conf_effects(没看出来有效果)1.2.16、Layout_conf_collapsed(给项目折叠时加上标题或者图片)dhxLayout.setCollapsedText("a", "Main Page");dhxLayout.setCollapsedText("b", "<img src='../common/labels/1.gif' width='18px' height='81px' border='0'>");dhxLayout.setCollapsedText("c", "<img src='../common/labels/2.gif' width='18px' height='106px' border='0'>");dhxLayout.setCollapsedText("d", "Comments");1.2.17、Layout_conf_header_footer(给layout加上header和footer)<script>var dhxLayout;function doOnLoad() {dhxLayout = new dhtmlXLayoutObject(document.body, "3L");dhxLayout.attachHeader("my_logo");dhxLayout.attachFooter("my_copy");}</script><div id="my_logo" style="height: 74px;">Hi! I'm header!</div><div id="my_copy" style="height: 74px;">Hi! I'm copyright ©!</div>1.2.18、Layout_global_menu(给layout的上面加上工具)dhxLayout = new dhtmlXLayoutObject("parentId", "3L");//加menudhxMenu = dhxLayout.attachMenu();dhxMenu.setIconsPath("common/imgs/");dhxMenu.loadXML("dhxmenu.xml?etc=" + new Date().getTime());//加toolbardhxToolbar =dhxLayout.attachToolbar();dhxToolbar.setIconsPath("common/imgs/");dhxToolbar.loadXML("common/dhxtoolbar_button.xml? etc=" + newDate().getTime());//加statusbarstatusBar = dhxLayout.attachStatusBar();statusBar.setText("Simple Status Bar");1.2.19、Layout_ components_XX(给layout加上各种的组件)(1)tree树dhxTree = dhxLayout.cells("a").attachTree();dhxTree.setImagePath("codebase/imgs/csh_vista/");dhxTree.loadXML("common/tree.xml?etc=" + new Date().getTime()); (2)grid格子、网格dhxGrid = dhxLayout.cells("a").attachGrid();dhxGrid.setImagePath("../../../dhtmlxGrid/codebase/imgs/"); dhxGrid.loadXML("../common/grid.xml?etc=" + new Date().getTime()); (3)treegrid树状的格子dhxTreeGrid = dhxLayout.cells("a").attachGrid();dhxTreeGrid.setImagePath("../../../dhtmlxGrid/codebase/imgs/"); dhxTreeGrid.loadXML("common/treegrid.xml?etc=" + newDate().getTime());(4)accordion折叠框dhxLayout.cells("a").hideHeader();dhxAccord = dhxLayout.cells("a").attachAccordion();dhxAccord.addItem("a1", "a");dhxAccord.addItem("a2", "b");dhxAccord.addItem("a3", "c");dhxAccord.openItem("a1");(5)editor编辑域dhtmlx.image_path = "codebase/imgs/";dhxEditor = dhxLayout.cells("a").attachEditor();(6)menu菜单dhxMenu = dhxLayout.cells("a").attachMenu();dhxMenu.setIconsPath("../../../dhtmlxMenu/samples/common/imgs/"); dhxMenu.loadXML("../../../dhtmlxMenu/samples/common/dhxmenu.xml?etc=" + new Date().getTime());(7)toolbar工具栏dhxLayout.cells("a").setWidth(350);dhxToolbar = dhxLayout.cells("a").attachToolbar();dhxToolbar.setIconsPath("common/imgs/");dhxToolbar.loadXML("common/dhxtoolbar_button.xml?" + newDate().getTime());(8)statusbar状态栏statusBar = dhxLayout.cells("a").attachStatusBar();statusBar.setText("Simple Status Bar");(9)mapsdhxLayout.cells("a").setWidth(120);GMaps = dhxLayout.cells("b").attachMap();(10)tabbar标签栏dhxTabbar = dhxLayout.cells("a").attachTabbar();dhxTabbar.setImagePath("dhtmlxTabbar/codebase/imgs/");dhxTabbar.loadXML("common/tabbar.xml?etc=" + new Date().getTime()); 1.2.20、Layout_events_XXX(监听layout上的事件)(1)记录layout是否折叠function doOnLoad(){var dhxLayout = new dhtmlXLayoutObject("parentId", "5I");dhxLayout.attachEvent("onExpand", doOnExpand);dhxLayout.attachEvent("onCollapse", doOnCollapse);}function doOnExpand(itemId){//打开的监听document.getElementById("log").innerHTML+= "<b>onExpand</b> event called, item id is <b>" + itemId + "</b><br>";}function doOnCollapse(itemId){//和上的监听document.getElementById("log").innerHTML += "<b>onCollapse</b> event called, item id is <b>" + itemId + "</b><br>";}(2)记录layout是否改变了大小function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "5I");dhxLayout.attachEvent("onPanelResizeFinish", doOnPanelResize);}function doOnPanelResize(ids){document.getElementById("log").innerHTML +="<b>onPanelResizeFinish</b> event called, used items are <b>" +ids.toString() + "</b><br>";}(3)记录layout所在的windows改变了大小function doOnLoad(){dhxWins = new dhtmlXWindows();dhxWins.setImagePath("../../../dhtmlxWindows/codebase/imgs/");dhxLayout = new dhtmlXLayoutObject(dhxWins.createWindow("w1", 40, 340, 600, 400), "3L");dhxLayout.attachEvent("onResize", function(){document.getElementById("log").innerHTML += "<b>onResize</b> event called, layout was resized<br>";});}(4)layout是否锁定,至少要有一个是锁定状态的function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "3L");dhxLayout.dhxWins.enableAutoViewport(false);dhxLayout.dhxWins.attachViewportTo("winVP");dhxLayout.attachEvent("onDock", doOnDock);dhxLayout.attachEvent("onUnDock", doOnUnDock);dhxLayout.cells("a").attachObject("objA");dhxLayout.cells("b").attachObject("objB");dhxLayout.cells("c").attachObject("objC");}function doOnDock(itemId){document.getElementById("log").innerHTML += "<b>onDock</b> event called, item id is <b>" + itemId + "</b><br>";}function doOnUnDock(itemId){document.getElementById("log").innerHTML+= "<b>onUnDock</b> event called, item id is <b>" + itemId + "</b><br>";dhxLayout.dhxWins.window(itemId).keepInViewport(true);}(5)记录鼠标双击的哪个项目function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "3L");dhxLayout.attachEvent("onDblClick", doOnDblClick);}function doOnDblClick(itemId){document.getElementById("log").innerHTML += "<b>onDblClick</b> event called, item id is <b>" + itemId + "</b><br>";}(6)记录哪个项目加载了哪个网站function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "3U");dhxLayout.attachEvent("onContentLoaded", doOnContentLoaded);dhxLayout.cells("a").setHeight(200);dhxLayout.cells("a").attachURL("/");dhxLayout.cells("b").attachURL("/");dhxLayout.cells("c").attachURL("/");}function doOnContentLoaded(itemId){document.getElementById("log").innerHTML +="<b>doOnContentLoaded</b> event called, item id is <b>" + itemId + "</b><br>";}2、Accordion2.1基本用法2.1.1、Accordion_init_objectdhxAccord = new dhtmlXAccordion("accordObj");dhxAccord.addItem("a1", "Main Page");dhxAccord.addItem("a2", "Site Navigation");dhxAccord.addItem("a3", "Support & Feedback");dhxAccord.addItem("a4", "Comments");2.1.2、Accordion_init_windowdhxWins = new dhtmlXWindows();dhxWins.enableAutoViewport(false);dhxWins.attachViewportTo("winVP");dhxWins.setImagePath("../../../dhtmlxWindows/codebase/imgs/");w1 = dhxWins.createWindow("w1", 20, 30, 400, 350);w1.setText("dhtmlxWindow with dhtmlxAccordion");dhxAccord = w1.attachAccordion();dhxAccord.addItem("a1", "Main Page");dhxAccord.addItem("a2", "Site Navigation");dhxAccord.addItem("a3", "Support & Feedback");dhxAccord.addItem("a4", "Comments");dhxAccord.openItem("a1");2.1.3、Accordion_init_layout。
Layout是一种常见的布局方式,它使用XML文件来描述界面布局。
Layout布局可以用于Android应用程序的界面设计。
在Layout布局中,可以使用各种属性来控制界面元素的位置和大小。
例如,可以设置控件的宽度和高度、边距、背景色等。
以下是一些Layout布局的常用属性:
* `android:layout_width`和`android:layout_height`: 用于设置控件的宽度和高度。
* `android:layout_margin`、`android:layout_marginLeft`、`android:layout_marginTop`、`android:layout_marginRight`和`android:layout_marginBottom`: 用于设置控件的边距。
* `android:background`: 用于设置控件的背景色或背景图片。
* `android:layout_weight`: 用于设置控件在水平或垂直方向上所占的比例。
* `android:singleLine`: 用于控制文本是否自动换行。
除了以上常用属性外,Layout布局还支持其他许多属性,可以根据实际需要进行使用。
目录detachHeader(index) (2)enableAutoHeight(mode,maxHeight, countFullHeight) (2)enableAutoWidth (mode, max_limit, min_limit) (2)enableCellIds(mode) (2)enableHeaderImages(fl) (3)init (3)setAwaitedRowHeight(height) (3)setCSVDelimiter(str) (3)setColAlign(alStr) (3)setColSorting(sortStr) (4)setColTypes(typeStr) (4)setColVAlign(valStr) (4)setDelimiter (delim) (4)setHeader (hdrStr, splitSign, styles) (5)setIconPath (path) (5)setImagePath (path) (5)setInitWidths (wp) (5)setInitWidthsP(wp) (6)setNoHeader(fl) (6)setSkin(name) (6)setStyle (ss_header, ss_grid, ss_selCell, ss_selRow) (6)uid (6)detachHeader(index)参数:index 表头索引用途:删除grid的某个表头,与attachHeader配对使用enableAutoHeight(mode,maxHeight, countFullHeight)参数:mode: true/falsemaxHeight: 最大无滚动高度,默认为无限制countFullHeight: 最大高度计算方式,true 最大高度表示所有表格高度总和,false 仅表示数据表格的高度总和,即除去header 和footer,默认为false。
dHtmlxGrid使用手册Phoenixjava 整理于2011-11-02目录一、dhtmlxGrid 介绍 (7)1.自定义XML: (7)2.支持多行表头、表尾展现 (7)3.移动、添加、删除列 (8)4.处理大型数据集-支持分页 (8)5.处理大型数据集-智能渲染 (9)6.与数据库交互 (9)7.扩展单元格-EXCEL (10)8.拆分模式(冻结栏) (10)9.控制于一体的网络和树 (11)二、dhtmlxgrid 配置部分 (12)2.1 表格操作API (12)2.1.1 attachEvent(evName , evHandler) (12)2.1.2 attachFooter(values, style) (14)2.1.3 attachHeader(values, style) (15)2.1.4 attachToObject(obj) (16)2.1.5 destructor (17)2.1.6 detachEvent(id) (17)2.1.7 detachFooter(index) (18)2.2 表格样式API (19)2.2.1 detachHeader(index) (19)2.2.2 enableAutoHeight(mode,maxHeight, countFullHeight) (19)2.2.3 enableAutoWidth (mode, max_limit, min_limit) (20)2.2.4 enableCellIds(mode) (21)2.2.5 enableHeaderImages(fl) (21)2.2.6 init (22)2.2.7 setAwaitedRowHeight(height) (22)2.2.8 setCSVDelimiter(str) (22)2.2.9 setColAlign(alStr) (23)2.2.10 setColSorting(sortStr) (23)2.2.11 setColTypes(typeStr) (24)2.2.12 setColVAlign(valStr) (24)2.2.13 setColWidth (ind, value) (24)2.2.14 setDelimiter (delim) (25)2.2.15 setHeader (hdrStr, splitSign, styles) (25)2.2.16 setIconPath (path) (26)2.2.17 setImagePath (path) (26)2.2.18 setInitWidths (wp) (27)2.2.19 setInitWidthsP(wp) (27)2.2.20 setNoHeader(fl) (28)2.2.21 setSkin(name) (28)2.2.22 setStyle (ss_header, ss_grid, ss_selCell, ss_selRow) (29)2.2.23uid (29)三、数据处理部分 (30)3.1 dhtmlxgrid 数据加载部分 (30)3.1.31 changePage(pageNum) (30)3.1.32 changePageRelative(ind) (30)3.1.33 clearAll(header) (30)3.1.34 clearAndLoad (url, call, type) (30)3.1.35 enableCSV AutoID(mode) (31)3.1.36 enableCSVHeader(mode) (31)3.1.37 enableDistributedParsing (mode, count, time) (31)3.1.38 enablePaging (31)3.1.39 enableSmartRendering (mode,buffer,reserved) (32)3.1.40 getRowAttribute (rId, name) (32)3.1.41 getStateOfView (32)3.1.43 load (url, call, type) (33)3.1.44 loadCSVFile (path,afterCall) (33)3.1.45 loadCSVString(str) (34)3.1.46 parse(data,call,type) (34)3.1.47 preventIECaching(mode) (34)3.1.48 setPagingSkin(name) (34)3.1.49 setPagingTemplates(navigation_template,info_template) (35)3.1.50 setPagingWTMode(navButtons,navLabel,pageSelect,perPageSelect) (35)3.1.51 setRowAttribute(rId, name, value) (35)3.1.52 setUserData (row_id, name, value) (35)3.1.53 startFastOperations (36)3.1.54 stopFastOperations (36)3.1.55 updateFromXML (url, insert_new, del_missed, afterCall) (36)3.2 dhtmlxgrid 保存数据操作 (36)3.2.160 enableMathSerialization (mode) (37)3.2.161 serialize (37)3.2.162 serializeToCSV (textmode) (37)3.2.163 setFieldNam (mask) (37)3.2.164 setSerializableColumns (list) (37)3.2.165 setSerializationLevel (userData, selectedAttr, config, changedAttr, onlyChanged,asCDATA) (38)四、Dhtmlxgrid操作 (39)4.1 dhtmlxgrid 行操作 (39)4.1.56 addRow (new_id, text, ind) (39)4.1.57 changeRowId (oldRowId, newRowId) (40)4.1.58 copyRowContent (from_row_id, to_row_id) (40)4.1.59 deleteRow(row_id) (40)4.1.60 deleteSelectedRows (40)4.1.61 doesRowExist(row_id) (41)4.1.62 enableAlterCss (cssE, cssU, perLevel, levelUnique) (41)4.1.63 enableMultiline(state) (41)4.1.64 enableRowsHover (mode, cssClass) (42)4.1.65 enableRowspan (42)4.1.66 forEachRow (custom_code) (42)4.1.67 getAllRowIds(separator) (43)4.1.68 getChangedRows (and_added) (43)4.1.69 getCheckedRows (col_ind) (43)4.1.70 getRowId(ind) (43)4.1.71 getRowIndex(row_id) (44)4.1.72 getRowsNum (44)4.1.73 getSelectedRowId (44)4.1.74 lockRow(rowId,mode) (44)4.1.75 moveRow (rowId,mode,targetId,targetGrid) (44)4.1.76 moveRowDown(row_id) (45)4.1.77 moveRowTo(srowId,trowId,mode,dropmode,sourceGrid,targetGrid) (45)4.1.78 moveRowUp(row_id) (45)4.1.79 selectRow (rIndex, fl, preserve, show) (46)4.1.80 selectRowById (row_id, preserve, show, call) (46)4.1.81 setCheckedRows (cInd,v) (46)4.1.82 setRowColor(row_id,color) (46)4.1.83 setRowExcellType (rowId, type) (47)4.1.84 setRowHidden (id, state) (47)4.1.85 setRowId (ind, row_id) (47)4.1.86 setRowTextBold (row_id) (47)4.1.87 setRowTextNormal(row_id) (48)4.1.88 setRowTextStyle (row_id, styleString) (48)4.1.89 showRow (rowID) (48)4.2 dhtmlxgrid 列操作 (48)4.2.90 adjustColumnSize(cind) (48)4.2.91 deleteColumn(ind) (49)4.2.92 enableColumnMove (mode,columns) (49)4.2.93 enableHeaderMenu (49)4.2.94 enableResizing(list) (49)4.2.95 enableTooltips(list) (49)4.2.96 getColIndexById (id) (50)4.2.97 getColType(index) (50)4.2.98 getColTypeById (cID) (50)4.2.99 getColWidth (ind) (50)4.2.100 getColumnId (cin) (51)4.2.101 getColumnLabel (cin, ind) (51)4.2.102 getColumnsNum (51)4.2.103 getFooterLabel (cin, ind) (51)4.2.104 insertColumn(ind,header,type,width,sort,align,valign,reserved,columnColor) (51)4.2.106 moveColumn (oldInd,newInd) (52)4.2.107 setColumnColor (clr) (52)4.2.108 setColumnExcellType (colIndex, type) (53)4.2.109 setColumnHidden (ind, state) (53)4.2.110 setColumnId (ind, id) (53)4.2.111 setColumnIds (ids) (53)4.2.112 setColumnLabel (col, label, ind) (53)4.2.113 setColumnMinWidth (width, ind) (54)4.2.114 setColumnsVisibility (list) (54)4.2.115 setFooterLabel (c, label, ind) (54)4.3 dhtmlxgrid 单元格操作 (55)4.3.116 cellById (row_id, col) (55)4.3.117 cellByIndex (row_index, col) (55)4.3.118 cells(row_id, col) (55)4.3.119 cells2 (row_index, col) (55)4.3.120 checkAll(mode) (55)4.3.121 clearChangedState (56)4.3.122 editCell (56)4.3.123 editStop (56)4.3.124 enableColSpan (mode) (56)4.3.125 enableEditEvents (click, dblclick, f2Key) (56)4.3.126 enableMarkedCells (mode) (57)4.3.127 enableMathEditing (mode) (57)4.3.128 forEachCell (rowId, custom_code) (57)4.3.129 getCombo (col_ind) (57)4.3.130 getCustomCombo (id, ind) (57)4.3.131 getMarked (58)4.3.132 getSelectedCellIndex (58)4.3.133 mark (rid,cindex,fl) (58)4.3.134 selectCell (r, cInd, fl, preserve, edit, show) (58)4.3.135 setCellExcellType (rowId, cellIndex, type) (59)4.3.136 setCellTextStyle (row_id, ind, styleString) (59)4.3.137 setColspan (row_id, col_ind, colspan) (59)4.3.138 setDateFormat (mask) (60)4.3.139 setEditable (mode) (60)4.3.140 setMathRound (digits) (60)4.3.141 setNumberFormat (mask, cInd, p_sep, d_sep) (60)4.3.142 setRowspan (rowID,colInd,length) (61)4.3.143 uncheckAll (61)4.3.144 unmarkAll (61)4.4 dhtmlxgrid 选择过滤操作 (61)4.4.144 clearSelection (61)4.4.145 enableBlockSelection(mode) (62)4.4.147 forceLabelSelection(mode) (62)4.4.148 selectAll (62)4.4.149 enableStableSorting (mode) (62)4.4.150 getSortingState (63)4.4.151 setCustomSorting (func, col) (63)4.4.152 setSortImgState (state, ind, order, row) (63)4.4.153 sortRows (col, type, order) (64)4.4.154 collectValues (column) (64)4.4.155 filterBy (column, value, preserve) (64)4.4.156 filterByAll (65)4.4.157 findCell (value, c_ind, first) (65)4.4.158 getFilterElement (index) (65)4.4.159 makeFilter (id,column,preserve) (66)一、dhtmlxGrid 介绍dhtmlxGrid 启用Ajax的JavaScript网格控制与尖端功能,强大的数据绑定,并与大型数据集的出色表现。
dhtmlx react 使用方法dhtmlx是一个流行的JavaScript框架,它提供了一系列的UI控件和工具,使得网页开发更加容易和高效。
而React是一种JavaScript框架,可以帮助开发者更容易地构建复杂的Web应用程序。
在本文中,我们将详细介绍如何使用dhtmlx与React构建Web应用程序。
1.通过NPM安装dhtmlx在开始使用dhtmlx和React之前,我们需要通过NPM安装dhtmlx。
在命令行中输入以下命令:```npm install dhtmlx-gantt```这将安装最新版本的dhtmlx-gantt库。
您可以在自己的项目中安装任何dhtmlx库,以便根据需要使用它们。
2.创建React组件在React中,UI被组织成组件的形式。
我们需要创建一个React组件来包含我们的dhtmlx代码。
在以下示例中,我们将创建一个名为GanttChart的组件:```Javascriptimport React, {Component} from 'react';export default class GanttChart extends Component {componentDidMount() {// DHTMLX code here}render() {return (<div id="gantt-container"></div>);}}```在渲染React组件时,将呈现一个包含一个具有“gantt-container”id的div元素。
3.初始化dhtmlx组件在React中,dhtmlx控件被使用window对象绑定到全局空间的方式来初始化。
使用以下步骤来初始化Gantt图,在componentDidMount 生命周期中添加以下内容:```JavascriptcomponentDidMount() {("gantt-container");window.gantt.parse([{id:1, text:"Project #1", start_date:"2020-09-01", duration:11, progress:0.6},{id:2, text:"Task #1", start_date:"2020-09-03", duration:5, progress:0.5, parent:1},{id:3, text:"Task #2", start_date:"2020-09-08", duration:5, progress:0.5, parent:1}]);}```在上面的代码中,我们使用()方法为Gantt图指定UI容器,然后使用gantt.parse()方法将任务数据加载到控件中。
DHTML技术应用5.3 DHTML技术应用5.3.1 层叠样式表CSS1. CSS的基本概念页面样式设定与页面内容分离。
把网页展现的样式从网页中独立出来集中管理,如果需要改变网页样式,只需要改变样式设定部分,HTML文件本身无须更改。
2.样式表的使用方式(1) 把CSS样式信息存成独立文件,使多个网页文件共享样式文件。
(2) 把样式分类,分存于不同的文件,如分为编排样式文件、字体样式文件、颜色样式文件等,把多个样式文件套用在一个网页文件上。
3.定义样式格式选择器 { 规则 }(1) 选择器(Selector):样式要套用的对象,一般是HTML标记,如h1。
在文件<h1>…</h1>标记之间的内容将全部继承h1的规则。
(2) 规则(Rule):样式设定的内容,用{}括起来的部分,如{ color:Blue;}4.样式表的应用例5.10:应用以下三种方式完成下图式的任务:(1)内联式样式单(2)嵌入式样式单(3)外部(链接)样式单(1)内联式样式单<h1style=“color:green;text-align:center;font-style:italic;font-size:x-large”>样式表的应用,应用样式 h1</p>(2) 嵌入式样式单<html><head><title>样式表css的应用</title><style type="text/css"> /*定义样式*/<!--h1 { color:green;text-align:center;font-style:italic;font-family:楷体;font-size:x-large;}--></style></head><body><h1>样式表的应用,应用样式 h1</h1></body></html>嵌入式样式单(3)外部(链接)样式单·ex05-010_1.css 保存文字的颜色·ex05-010_2.css 保存文字的其它样式· 建立样式文件ex05-010_1.css文件代码清单:h1 { color:green;}ex05-010_2.css文件代码清单下:h1 { text-align:center;font-style:italic;font-family:楷体;font-size:x-large;}· 在HTML文档的文件头中加入语句,建立与外部样式文件的链接。
QGridLayout 是Qt 框架中的一个布局管理器,用于在Qt 应用程序中创建网格布局。
它可以在Qt 的QWidget 子类上使用,以实现网格状的布局排列。
QGridLayout 提供了以下特点:- 自动调整网格大小:根据容器的大小自动调整网格行列数。
- 自动调整组件大小:根据网格单元格大小自动调整组件大小。
- 方便地添加和删除组件:通过添加和删除网格单元格来实现组件的添加和删除。
- 支持拉伸和压缩:可以设置网格单元格是否可以被拉伸或压缩,以实现自适应布局。
以下是使用QGridLayout 的基本步骤:1. 导入所需的库:```cpp#include <QGridLayout>#include <QWidget>```2. 创建一个QWidget 子类,用于承载网格布局:```cppclass MyWidget : public QWidget{Q_OBJECTpublic:explicit MyWidget(QWidget *parent = nullptr);private:QGridLayout *gridLayout;};```3. 在MyWidget 的构造函数中,创建一个QGridLayout 对象,并设置容器的大小:```cppMyWidget::MyWidget(QWidget *parent) : QWidget(parent){gridLayout = new QGridLayout(this);gridLayout->setContentsMargins(0, 0, 0, 0); // 设置网格布局的边距// 添加组件到网格布局中// 例如:gridLayout->addWidget(new QPushButton("Button 1"), 0, 0);// gridLayout->addWidget(new QPushButton("Button 2"), 0, 1);// gridLayout->addWidget(new QPushButton("Button 3"), 1, 0);// gridLayout->addWidget(new QPushButton("Button 4"), 1, 1);}```4. 实现QWidget 的布局管理器接口,以便使用QGridLayout:```cpp#include <QWidget>class MyWidget : public QWidget{Q_OBJECTpublic:explicit MyWidget(QWidget *parent = nullptr);void setLayout(QLayout *layout);private:QGridLayout *gridLayout;};MyWidget::MyWidget(QWidget *parent) : QWidget(parent){// ... 创建QGridLayout 并设置容器大小setLayout(gridLayout);}void MyWidget::setLayout(QLayout *layout){if (layout) {layout->setContentsMargins(0, 0, 0, 0); // 设置布局的边距QWidget::setLayout(layout);}}```5. 在主函数中,创建MyWidget 实例,并显示:```cppint main(int argc, char *argv[]){QApplication a(argc, argv);MyWidget w;w.show();return a.exec(); }```。
layout的用法摘要:一、layout 的定义和作用二、layout 的语法和使用方法三、layout 的常见应用场景四、使用layout 的注意事项五、结论正文:layout 是Python 中一个用于定义和控制文档结构的函数库。
它可以帮助开发者轻松地创建具有复杂结构的文档,如报表、简历、书籍等。
layout 的使用方法简单,功能强大,是Python 开发者必备的工具之一。
首先,我们来看一下layout 的语法。
layout 函数的基本语法如下:```pythonfrom layout import *doc = Document()doc.add(Component())```其中,`from layout import *`是导入layout 库中的所有模块;`doc = Document()`创建一个文档对象;`doc.add(Component())`将组件添加到文档中。
接下来,我们来看一下layout 的常见应用场景。
首先,layout 可以用于创建报表。
通过使用layout,开发者可以轻松地创建具有多个表格、图表和图片的报表。
其次,layout 可以用于创建简历。
使用layout,开发者可以快速地创建一个结构清晰、内容丰富的简历。
最后,layout 还可以用于创建书籍、手册等文档。
然而,在使用layout 时,也有一些需要注意的事项。
首先,开发者需要确保组件的尺寸和位置合适。
如果不合适,可能会导致文档结构混乱。
其次,开发者需要避免在文档中使用过多的组件。
如果组件过多,可能会导致文档加载缓慢,影响用户体验。
总之,layout 是一个非常有用的Python 函数库,可以帮助开发者轻松地创建具有复杂结构的文档。
Layout命令应用技巧(培训)在编排页面和布局内容方面,Layout命令是一种非常有用的工具。
它允许用户创建复杂和吸引人的页面布局,并能够以专业和一致的方式展示内容。
以下是一些使用Layout命令的技巧,可以帮助您在培训材料中创建出色的页面设计。
1. 使用网格和栅格系统:网格和栅格系统是Layout命令的核心组成部分,可以帮助您将页面分割为等大的列和行。
这样,您可以更容易地对齐和布局内容。
例如,在一个内容页中,您可以将其分为两列,左侧用于标题和正文,右侧用于图片或其他相关信息。
使用栅格的好处是可以确保页面保持一致和平衡的外观,同时可以更容易地改变布局和重新排列内容。
2.使用固定和自适应布局:固定布局指定了页面元素的确切位置和大小。
这在希望控制布局的情况下非常有用,比如在固定的幻灯片和布局中。
另一方面,自适应布局允许页面根据屏幕或窗口的大小自动调整内容的大小和位置。
这对于可以在不同设备上查看的培训材料非常重要,以确保内容始终呈现出人性化的外观。
3. 利用样式和模板:Layout命令还允许用户创建和使用样式和模板。
样式是为特定类型的内容创建的预定义格式,比如标题、段落或列表的样式。
而模板是一种预定义的布局,可以在不同页面和篇章中使用,以确保一致的外观和样式。
使用样式和模板可以提高页面设计的效率,并确保材料的一致性。
4. 添加背景和边框:除了基本的页面布局之外,Layout命令还允许用户为页面添加背景和边框。
背景可以是纯色、渐变色或图像,可以为页面添加专业和吸引人的外观。
边框可以用来强调页面的内容或创建不同部分之间的分隔线。
通过使用背景和边框,您可以增强材料的可视吸引力,并帮助读者更好地理解和记忆所呈现的信息。
5. 使用间距和对齐:在设计布局时,控制页面元素之间的间距和对齐是至关重要的。
Layout命令允许您调整元素的间距和对齐方式,以确保页面看起来整洁和协调。
在创建培训材料时,确保标题、段落、列表等元素之间的间距适当且一致,以提高可读性和可视外观。
1、Layout: (2)1.1常用的布局样式: (2)1.2基本用法: (2)1.2.1、Layout_init_object(基本显示方式) (2)1.2.2、Layout_init_window(将其放入一个windows中) (2)1.2.3、Layout_init_fullscreen(全屏幕显示) (2)1.2.4、Layout_init_layout(在layout中套入layout完成复杂样式) (3)1.2.5、Layout_init_api(layout的部分api参数) (3)1.2.6、Layout_init_skinning(更换layout样式) (3)1.2.7、Layout_init_views(更换layout中的内容) (4)1.2.8、Layout_conf_access(修改layout的标题) (4)1.2.9、Layout_conf_id_index(根据索引得到id、根据id得到相应的索引值) (4)1.2.10、Layout_conf_iterator(为layout写入名字) (5)1.2.11、Layout_conf_autosize(没看明白) (5)1.2.12、Layout_conf_panels(通过button方法修改layout属性) (7)1.2.13、Layout_conf_attach_object(layout的项目中加入div并显示其中内容) .91.2.14、Layout_conf_attach_url(给项目加上url地址,可直接嵌入页面) (9)1.2.15、Layout_conf_effects(没看出来有效果) (10)1.2.16、Layout_conf_collapsed(给项目折叠时加上标题或者图片) (10)1.2.17、Layout_conf_header_footer(给layout加上header和footer) (10)1.2.18、Layout_global_menu(给layout的上面加上工具) (10)1.2.19、Layout_ components_XX(给layout加上各种的组件) (11)1.2.20、Layout_events_XXX(监听layout上的事件) (12)2、Accordion (14)2.1基本用法 (14)2.1.1、Accordion_init_object (14)2.1.2、Accordion_init_window (14)2.1.3、Accordion_init_layout (14)DHX总结记录:1、Layout:1.1常用的布局样式:1.2基本用法:1.2.1、Layout_init_object(基本显示方式)dhxLayout = new dhtmlXLayoutObject("parentId", "4I");在页面上显示1.2.2、Layout_init_window(将其放入一个windows中)var windows =new dhtmlXWindows();windows.enableAutoViewport(false);//控制窗口是否自动显示在页面上windows.attachViewportTo("winVP")//控制窗口显示在某个特定的div层中var window_3 = windows.createWindow('window_3',0,0,300,400);var layout_1 = window_3.attachLayout('3E');1.2.3、Layout_init_fullscreen(全屏幕显示)function openLayout(){window.open("inc/fullscreen_inner.html");//打开指定的新页面}1.2.4、Layout_init_layout(在layout中套入layout完成复杂样式)dhxLayout = new dhtmlXLayoutObject("parentId", "3L");layout1 = new dhtmlXLayoutObject(dhxLayout.cells("b"), "2U");1.2.5、Layout_init_api(layout的部分api参数)var dhxLayoutData = {parent: "parentId",//所属div的idpattern: "4H",//基本样式cells: [{id: "a",text: "Navigation",//每个框的显示的名字width: 100,header: false,//框头隐藏fix_size: [true, null]}, {id: "b",text: "Advertisement",height: 100}, {id: "c",text: "Main Page"}, {id: "d",text: "Links",collapse: true //默认不打开是折叠式的}]};dhxLayout = new dhtmlXLayoutObject(dhxLayoutData);dhxLayout.cells("a").attachObject("objId");//a中加入objId中的内容1.2.6、Layout_init_skinning(更换layout样式)document.getElementById("tr_" + activeSkin).style.backgroundColor = "#FFFFFF";activeSkin = skin;doOnLoad();document.getElementById("tr_" + activeSkin).style.backgroundColor = "#CFCFCF";1.2.7、Layout_init_views(更换layout中的内容)<input type="button"value="Grid"onclick='dhxLayout.cells("a").view("def").setActive();'><input type="button"value="Tree"onclick='dhxLayout.cells("a").view("tree").setActive();'>//两个按钮触发更换的事件function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "3L");dhxGrid = dhxLayout.cells("a").attachGrid();dhxGrid.setImagePath("../../../dhtmlxGrid/codebase/imgs/");dhxGrid.loadXML("../common/grid.xml?etc="+ new Date().getTime());dhxTree = dhxLayout.cells("a").view("tree").attachTree();dhxTree.setImagePath("../../../dhtmlxTree/codebase/imgs/csh_vista/");dhxTree.loadXML("../common/tree.xml?etc="+ new Date().getTime()); }1.2.8、Layout_conf_access(修改layout的标题)dhxLayout = new dhtmlXLayoutObject("parentId", "3J");// 通过 cells修改dhxLayout.cells("a").setText("The Secret of Monkey Island");// 通过items 修改dhxLayout.items[1].setText("Monkey Island 2: LeChuck's Revenge");1.2.9、Layout_conf_id_index(根据索引得到id、根据id得到相应的索引值)Get ID by Index <select id="inds"></select><input type="button"value="Get ID"onclick="getId();"> //根据索引求idGet Index by ID <select id="ids"></select><input type="button"value="Get Index"onclick="getIndex();"> //根据id获得索引var dhxLayout, ids, inds;function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "5I");ids = document.getElementById("ids");inds = document.getElementById("inds");dhxLayout.forEachItem(function(item){ //遍历layout向id、ids 中加入数据ids.options.add(new Option(item.getId(), item.getId()));inds.options.add(new Option(item.getIndex(),item.getIndex()));});}function getId(){var ind = inds.options[inds.selectedIndex].value;alert(dhxLayout.getIdByIndex(ind));}function getIndex(){var id = ids.options[ids.selectedIndex].value;alert(dhxLayout.getIndexById(id));}1.2.10、Layout_conf_iterator(为layout写入名字)var names = new Array("Gothic 3 Forsaken Gods", "The Bard's Tale", "NFS Undercover", "The Punisher", "Diablo 2 Lord Of Destruction");var newNames = true;var j = 0;var dhxLayout;function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "5I");}function update(){//改名字的方法dhxLayout.forEachItem(function(item){item.setText(newNames ? names[j++] : item.getId());});newNames = !newNames;j = 0;}1.2.11、Layout_conf_autosize(没看明白)<div id="winVP"style="position: relative; height: 500px; border:#cecece 1px solid; margin: 10px;"></div><div id="srcDiv"style="position: relative; left: 20px; width:600px;"></div><div style="position: relative; margin-top: 20px; left: 20px; width: 600px;">Please, select the cells which will be autosized in the process of resizing</div><div id="viewDiv"style="position: relative; margin-top: 20px; left: 20px; width: 600px;">Autosize: HOR <select id="sel1"></select> VER <selectid="sel2"></select><input type="button"value="Apply"onclick="setAutoSize();"></div><script>var dhxWins,dhxLayout;var sel1 = document.getElementById("sel1");var sel2 = document.getElementById("sel2");function doOnLoad(){dhxWins = new dhtmlXWindows();dhxWins.enableAutoViewport(false);dhxWins.attachViewportTo("winVP");dhxWins.setImagePath("../../../dhtmlxWindows/codebase/imgs/");dhxWins.createWindow("w1", 20, 30, 600, 400);loadView("3L");var views = dhxLayout.listViews();var table = document.createElement("TABLE");document.getElementById("srcDiv").appendChild(table);var tbody = document.createElement("TBODY");table.appendChild(tbody);var tr1 = document.createElement("TR");tbody.appendChild(tr1);var tr2 = document.createElement("TR");tbody.appendChild(tr2);for(var q = 0; q < views.length; q++){var td1 = document.createElement("TD");var td2 = document.createElement("TD");td1.innerHTML = views[q];td2.innerHTML = "<img src='../common/imgs/" +String(views[q]).toLowerCase()+ ".bmp' style='height: 49px; width: 49px; cursor: pointer;' onclick='loadView(\"" + views[q] + "\");'>";tr1.appendChild(td1);tr2.appendChild(td2);}}function loadView(view){if(dhxLayout != null)dhxLayout.unload();dhxLayout = dhxWins.window("w1").attachLayout(view);//;var asData = dhxLayout.listAutoSizes();sel1.options.length = 0;var selected = 0;for(var q = 0; q < asData[2].length; q++){if(asData[2][q] == asData[0]){selected = q;}sel1.options.add(new Option(asData[2][q].replace(/;/g, ""), asData[2][q]));}sel1.selectedIndex = selected;sel2.options.length = 0;var selected = 0;for(var q = 0; q < asData[3].length; q++){if(asData[3][q] == asData[1]){selected = q;}sel2.options.add(new Option(asData[3][q].replace(/;/g, ""), asData[3][q]));}sel2.selectedIndex = selected;}function setAutoSize(){var sel1 = document.getElementById("sel1");var as1 = sel1.options[sel1.selectedIndex].value;var sel2 = document.getElementById("sel2");var as2 = sel2.options[sel2.selectedIndex].value;//;dhxLayout.setAutoSize(as1, as2);}</script>1.2.12、Layout_conf_panels(通过button方法修改layout属性)<script>var dhxLayout;var sel = document.getElementById("sel");function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "3L");dhxLayout.forEachItem(function(item){sel.options.add(new Option(item.getId(), item.getIndex()));});}function getInd(){//得到id属性var sel = document.getElementById("sel");var id = sel.options[sel.selectedIndex].value;return id;}function setText(){ //修改layout标题dhxLayout.items[getInd()].setText(document.getElementById("txt").valu e);}function isVisible(){//判断标题是否隐藏(隐藏返回false、活动返回true)alert(dhxLayout.items[getInd()].isHeaderVisible());}function hidePanel(){//隐藏layout标题dhxLayout.items[getInd()].hideHeader();}function showPanel(){//显示layout标题dhxLayout.items[getInd()].showHeader();}function expand(){//展开所选择的项目dhxLayout.items[getInd()].expand();}function collapse(){//折叠所选择的项目dhxLayout.items[getInd()].collapse();}function setWidth(){//在总的允许的范围内设置项目的宽dhxLayout.items[getInd()].setWidth(Number(document.getElementById("it em_w").value));}function setHeight(){//在总的允许的范围内设置项目的高dhxLayout.items[getInd()].setHeight(Number(document.getElementById("i tem_h").value));}function getWidth(){//得到项目的宽alert(dhxLayout.items[getInd()].getWidth());}function getHeight(){//得到项目的宽alert(dhxLayout.items[getInd()].getHeight());}function fixSize(){//固定项目的长和宽dhxLayout.items[getInd()].fixSize((宽是否固定true固定、false不固定),(长是否固定));}function progressOn(fullLayout){//给layout、项目,加上进度条(不知道有什么用)if(fullLayout){dhxLayout.progressOn();}else{dhxLayout.items[getInd()].progressOn();}}function progressOff(fullLayout){//给layout、项目,去掉进度条if(fullLayout){dhxLayout.progressOff();}else{dhxLayout.items[getInd()].progressOff();}}</script>1.2.13、Layout_conf_attach_object(layout的项目中加入div并显示其中内容)<div id="parentId"style="position: relative; top: 20px; left: 20px; width: 600px; height: 400px; aborder: #B5CDE4 1px solid;"></div><div id="objId"style="width: 100%; height: 100%; overflow: auto; display: none; font-family: Tahoma; font-size: 11px;"><div style="margin: 3px 5px 3px 5px;">The film ends with Arthur and Guinevere's marriage. Merlin then proclaims him to be their king. King Arthur and his remaining knights promise to lead the Britons, now united after the Romans leave, against future invaders. The last scene shows Lancelot, Dagonet and Tristan roaming the lands freely as reincarnated horses as told in a legend by Lancelot's father.</div></div><script>var dhxLayout;function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "3U");dhxLayout.cells("a").setHeight(200);dhxLayout.cells("a").attachObject("objId");}1.2.14、Layout_conf_attach_url(给项目加上url地址,可直接嵌入页面)dhxLayout.cells("a").attachURL("/");1.2.15、Layout_conf_effects(没看出来有效果)1.2.16、Layout_conf_collapsed(给项目折叠时加上标题或者图片)dhxLayout.setCollapsedText("a", "Main Page");dhxLayout.setCollapsedText("b", "<img src='../common/labels/1.gif' width='18px' height='81px' border='0'>");dhxLayout.setCollapsedText("c", "<img src='../common/labels/2.gif' width='18px' height='106px' border='0'>");dhxLayout.setCollapsedText("d", "Comments");1.2.17、Layout_conf_header_footer(给layout加上header和footer)<script>var dhxLayout;function doOnLoad() {dhxLayout = new dhtmlXLayoutObject(document.body, "3L");dhxLayout.attachHeader("my_logo");dhxLayout.attachFooter("my_copy");}</script><div id="my_logo" style="height: 74px;">Hi! I'm header!</div><div id="my_copy" style="height: 74px;">Hi! I'm copyright ©!</div>1.2.18、Layout_global_menu(给layout的上面加上工具)dhxLayout = new dhtmlXLayoutObject("parentId", "3L");//加menudhxMenu = dhxLayout.attachMenu();dhxMenu.setIconsPath("common/imgs/");dhxMenu.loadXML("dhxmenu.xml?etc=" + new Date().getTime());//加toolbardhxToolbar =dhxLayout.attachToolbar();dhxToolbar.setIconsPath("common/imgs/");dhxToolbar.loadXML("common/dhxtoolbar_button.xml? etc=" + newDate().getTime());//加statusbarstatusBar = dhxLayout.attachStatusBar();statusBar.setText("Simple Status Bar");1.2.19、Layout_ components_XX(给layout加上各种的组件)(1)tree树dhxTree = dhxLayout.cells("a").attachTree();dhxTree.setImagePath("codebase/imgs/csh_vista/");dhxTree.loadXML("common/tree.xml?etc=" + new Date().getTime()); (2)grid格子、网格dhxGrid = dhxLayout.cells("a").attachGrid();dhxGrid.setImagePath("../../../dhtmlxGrid/codebase/imgs/"); dhxGrid.loadXML("../common/grid.xml?etc=" + new Date().getTime()); (3)treegrid树状的格子dhxTreeGrid = dhxLayout.cells("a").attachGrid();dhxTreeGrid.setImagePath("../../../dhtmlxGrid/codebase/imgs/"); dhxTreeGrid.loadXML("common/treegrid.xml?etc=" + newDate().getTime());(4)accordion折叠框dhxLayout.cells("a").hideHeader();dhxAccord = dhxLayout.cells("a").attachAccordion();dhxAccord.addItem("a1", "a");dhxAccord.addItem("a2", "b");dhxAccord.addItem("a3", "c");dhxAccord.openItem("a1");(5)editor编辑域dhtmlx.image_path = "codebase/imgs/";dhxEditor = dhxLayout.cells("a").attachEditor();(6)menu菜单dhxMenu = dhxLayout.cells("a").attachMenu();dhxMenu.setIconsPath("../../../dhtmlxMenu/samples/common/imgs/"); dhxMenu.loadXML("../../../dhtmlxMenu/samples/common/dhxmenu.xml?etc=" + new Date().getTime());(7)toolbar工具栏dhxLayout.cells("a").setWidth(350);dhxToolbar = dhxLayout.cells("a").attachToolbar();dhxToolbar.setIconsPath("common/imgs/");dhxToolbar.loadXML("common/dhxtoolbar_button.xml?" + newDate().getTime());(8)statusbar状态栏statusBar = dhxLayout.cells("a").attachStatusBar();statusBar.setText("Simple Status Bar");(9)mapsdhxLayout.cells("a").setWidth(120);GMaps = dhxLayout.cells("b").attachMap();(10)tabbar标签栏dhxTabbar = dhxLayout.cells("a").attachTabbar();dhxTabbar.setImagePath("dhtmlxTabbar/codebase/imgs/");dhxTabbar.loadXML("common/tabbar.xml?etc=" + new Date().getTime()); 1.2.20、Layout_events_XXX(监听layout上的事件)(1)记录layout是否折叠function doOnLoad(){var dhxLayout = new dhtmlXLayoutObject("parentId", "5I");dhxLayout.attachEvent("onExpand", doOnExpand);dhxLayout.attachEvent("onCollapse", doOnCollapse);}function doOnExpand(itemId){//打开的监听document.getElementById("log").innerHTML+= "<b>onExpand</b> event called, item id is <b>" + itemId + "</b><br>";}function doOnCollapse(itemId){//和上的监听document.getElementById("log").innerHTML += "<b>onCollapse</b> event called, item id is <b>" + itemId + "</b><br>";}(2)记录layout是否改变了大小function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "5I");dhxLayout.attachEvent("onPanelResizeFinish", doOnPanelResize);}function doOnPanelResize(ids){document.getElementById("log").innerHTML +="<b>onPanelResizeFinish</b> event called, used items are <b>" +ids.toString() + "</b><br>";}(3)记录layout所在的windows改变了大小function doOnLoad(){dhxWins = new dhtmlXWindows();dhxWins.setImagePath("../../../dhtmlxWindows/codebase/imgs/");dhxLayout = new dhtmlXLayoutObject(dhxWins.createWindow("w1", 40, 340, 600, 400), "3L");dhxLayout.attachEvent("onResize", function(){document.getElementById("log").innerHTML += "<b>onResize</b> event called, layout was resized<br>";});}(4)layout是否锁定,至少要有一个是锁定状态的function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "3L");dhxLayout.dhxWins.enableAutoViewport(false);dhxLayout.dhxWins.attachViewportTo("winVP");dhxLayout.attachEvent("onDock", doOnDock);dhxLayout.attachEvent("onUnDock", doOnUnDock);dhxLayout.cells("a").attachObject("objA");dhxLayout.cells("b").attachObject("objB");dhxLayout.cells("c").attachObject("objC");}function doOnDock(itemId){document.getElementById("log").innerHTML += "<b>onDock</b> event called, item id is <b>" + itemId + "</b><br>";}function doOnUnDock(itemId){document.getElementById("log").innerHTML+= "<b>onUnDock</b> event called, item id is <b>" + itemId + "</b><br>";dhxLayout.dhxWins.window(itemId).keepInViewport(true);}(5)记录鼠标双击的哪个项目function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "3L");dhxLayout.attachEvent("onDblClick", doOnDblClick);}function doOnDblClick(itemId){document.getElementById("log").innerHTML += "<b>onDblClick</b> event called, item id is <b>" + itemId + "</b><br>";}(6)记录哪个项目加载了哪个网站function doOnLoad(){dhxLayout = new dhtmlXLayoutObject("parentId", "3U");dhxLayout.attachEvent("onContentLoaded", doOnContentLoaded);dhxLayout.cells("a").setHeight(200);dhxLayout.cells("a").attachURL("/");dhxLayout.cells("b").attachURL("/");dhxLayout.cells("c").attachURL("/");}function doOnContentLoaded(itemId){document.getElementById("log").innerHTML +="<b>doOnContentLoaded</b> event called, item id is <b>" + itemId + "</b><br>";}2、Accordion2.1基本用法2.1.1、Accordion_init_objectdhxAccord = new dhtmlXAccordion("accordObj");dhxAccord.addItem("a1", "Main Page");dhxAccord.addItem("a2", "Site Navigation");dhxAccord.addItem("a3", "Support & Feedback");dhxAccord.addItem("a4", "Comments");2.1.2、Accordion_init_windowdhxWins = new dhtmlXWindows();dhxWins.enableAutoViewport(false);dhxWins.attachViewportTo("winVP");dhxWins.setImagePath("../../../dhtmlxWindows/codebase/imgs/");w1 = dhxWins.createWindow("w1", 20, 30, 400, 350);w1.setText("dhtmlxWindow with dhtmlxAccordion");dhxAccord = w1.attachAccordion();dhxAccord.addItem("a1", "Main Page");dhxAccord.addItem("a2", "Site Navigation");dhxAccord.addItem("a3", "Support & Feedback");dhxAccord.addItem("a4", "Comments");dhxAccord.openItem("a1");2.1.3、Accordion_init_layout。