然后dhtmlxLayout单元格被折叠,如何将标题文本设置为居中对齐以及如何使整个标签单元格处于折叠状态时可单击? 我有下一个代码:
save
答案 0 :(得分:2)
您可以尝试下一种方法:
var h, panName;
function doOnLoad() {
dhxLayout = new dhtmlXLayoutObject(document.body, "3U");
//put cell text in a div
dhxLayout.cells('a').setText('<div id="a">Text to Center</div>');
dhxLayout.cells('b').setText('<div id="b">Text to Center</div>');
//use double click to collapse/expand cell
dhxLayout.attachEvent("onDblClick", function (itemId){
if (dhxLayout.cells(itemId).isCollapsed() == false){
dhxLayout.cells(itemId).collapse();
}
else dhxLayout.cells(itemId).expand();
});
//center the label
dhxLayout.attachEvent("onCollapse", function(name){
panName = name;
recount(panName)
});
dhxLayout.attachEvent("onPanelResizeFinish", function(){
recount(panName)
});
dhxLayout.attachEvent("onResizeFinish", function(){
recount(panName)
});
}
function recount(panName){
h = dhxLayout.cells("a").getHeight();
document.getElementById(panName).style.width = (h-20)+"px";
document.getElementById(panName).style.textAlign = 'center';
}