2

有人可以帮助我吗?我想实现放置在 BorderContainer 内的 ContentPane 的自动调整大小。这是一个简单的测试用例:http: //jsfiddle.net/3dft2/1/ 在这种情况下,我在 ContentPane 中有 TitlePane(但一般来说,它可能是里面的任何内容)。当我单击 TitlePane (它打开 => 内容高度更改)时,我想相应地自动调整 ContentPane 的大小。即我想移动分离器。如何归档这个?如果更改了此大小,如何查看内容大小(无论是哪种内容)并自动调整 ContentPane 的大小?

测试用例:

dojo.require("dijit.TitlePane");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.BorderContainer");
dojo.ready(function() {
     // create a BorderContainer as the top widget in the hierarchy
    var bc = new dijit.layout.BorderContainer({
        style: "height: 300px; width: 500px;"
    });

    var TitlePane = new dijit.TitlePane({
        title: 'title pane',
        open: false,
        content: "Collapse me!"        
    });

    // create a ContentPane as the left pane in the BorderContainer
    var cp1 = new dijit.layout.ContentPane({
        region: "top",
        style: "width: 100px",
        content: TitlePane,
        splitter: "true"
    });
    bc.addChild(cp1);

    // create a ContentPane as the center pane in the BorderContainer
    var cp2 = new dijit.layout.ContentPane({
        region: "center",
        content: "how are you?"
    });
    bc.addChild(cp2);

    // put the top level widget into the document, and then call startup()
    bc.placeAt(document.body);
    bc.startup();
});
4

1 回答 1

0

当标题窗格折叠时,使用它的样式属性相应地减小高度。当它展开时,您可以根据需要设置添加高度。无论如何,已经有方法了。我们只需要添加设置高度的代码。也许,如果你有滚动条,那是你的问题,那么增加 Border 容器的高度。内容窗格默认自动调整大小。

于 2013-12-10T07:23:18.307 回答