更改borderContainer中contentPane的拆分器位置



我使用Dojo Toolkit在BorderContainer中有两个contentPane。很像以下内容:

<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的大小,而不仅仅是移动拆分器的位置。我不想更改外部边框Container的大小。

我在这里找到了一些有用的代码来回答我的问题:

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();
});
_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));

最新更新