我使用contentPanes在BorderContainer内有2个Dojo Toolkit。与以下内容非常相似:
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'sidebar', gutters:true, liveSplitters:true" id="borderContainerB" style="height: 200px">
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true, region:'top'" style="width: 100px;">Hi, I'm leading pane<br><br>Lots of stuff goes here.</div>
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="splitter:true, region:'center'">Hi, I'm center pane</div>
</div>
我想使用JavaScript以编程方式更改拆分器的位置。在一种情况下,我想将它一直移到侧面,因此只能看到一个contentPane。如何更改拆分器位置?
已经尝试过:
var datasetArea = document.getElementById("studiesDatasetArea");
datasetArea.style.height = newHeight + "px";
哪个不起作用,以及:
dojo.widget.byId('studiesDatasetArea').resizeTo(400, newHeight);
更改了borderContainer的大小,而不仅仅是移动拆分器的位置。我不想改变外部borderContainer的大小。
答案 0 :(得分:2)
我在这里找到了一些有用的代码来回答我的问题:
http://telliott.net/dojoExamples/dojo-bcExample.html
摘录:
require(["dijit/registry"],
function(registry)
{
var myBC = registry.byId("studiesBorderContainer"); // actual JS object
var topPane = registry.byId("studiesTableArea");
dojo.style(topPane.domNode, "height", (800-newHeight)+"px");
myBC.resize();
});
答案 1 :(得分:0)
_layoutChildren: function(/*String?*/ changedChildId, /*Number?*/ changedChildSize){
// summary:
// This is the main routine for setting size/position of each child.
// description:
// With no arguments, measures the height of top/bottom panes, the width
// of left/right panes, and then sizes all panes accordingly.
//
// With changedRegion specified (as "left", "top", "bottom", or "right"),
// it changes that region's width/height to changedRegionSize and
// then resizes other regions that were affected.
// changedChildId:
// Id of the child which should be resized because splitter was dragged.
// changedChildSize:
// The new width/height (in pixels) to make specified child
//example:
var bc = digit.byId(‘borderContainerId’);
var newSize = 150;
var childContentPaneId = ‘myPaneId’;
dojo.hitch(bc, bc._layoutChildren(‘childContentPaneId’,newSize));