dojo contentpane-默认情况下如何关闭它

时间:2012-05-03 18:29:25

标签: dojo dijit.layout

我已经设置了一个包含一些dojo小部件的布局,并且希望默认情况下关闭包含contentpanes的侧面菜单。会发生的是第一个保持打开并导致其他内容窗格消失。顺便说一句,内容窗格都在一个手风琴容器中

<!doctype html>
<html lang="en" dir="ltr">
<head>
   <script src=
     "https://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js"
      djConfig="parseOnLoad: true"></script>


    <title>Dijit Template</title>
    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/
      libs/dojo/1.5/dijit/themes/claro/claro.css" />
    </head>
    <body class="claro">
    <div style="width: 535px; height: 290px">
    <div dojoType="dijit.layout.BorderContainer" style="width: 100%; 
     height: 100%;">
    <div dojoType="dijit.layout.ContentPane" region="top" splitter="true">
        This is the content in the top section.
    </div>
    <div dojoType="dijit.layout.ContentPane" region="left" style="width: 100px;" 
      splitter="true">
        <div dojoType="dijit.layout.AccordionContainer"minSize="20" 
         style="width:  300px;" id="leftAccordion" region="leading" splitter="true">
         <div dojoType="dijit.layout.ContentPane" title="HOME">
          </div>
         <div dojoType="dijit.layout.ContentPane" title="INSTANCES">
          <div dojoType="dijit.TitlePane" title="Reader01">
                    </div>
       </div>
      <div dojoType="dijit.layout.ContentPane" title="DISCOVERY">
                  </div>
     </div><!-- end AccordionContainer -->
    </div>
    <div dojoType="dijit.layout.ContentPane" region="center" splitter="true">
        This is the content in the center section.
    </div>
    <div dojoType="dijit.layout.ContentPane" region="right" 
            style="width: 100px;"splitter="true">
        This is the content in the right section.
    </div>
    <div dojoType="dijit.layout.ContentPane" region="bottom" splitter="true">
         This is the content in the bottom section.
     </div>
 </div>
  </div>




</body>
</html>​

1 个答案:

答案 0 :(得分:1)

在AccorionContainer的addChild函数中,您将看到以下行

this.layout();
if(!this.selectedChildWidget){
   this.selectChild(child);
}
总是会选择一个孩子,但是让我们在这里画一条线

试试这个,它是你的代码片段,在我们将设置选中的所有其他内容窗格(家庭,实例等)上添加一个空子,并隐藏onload

        <div dojoType="dijit.layout.AccordionContainer"  
         style="width:  300px;" id="leftAccordion" region="leading" splitter="true">
            <script type="dojo/connect" events="onLoad">
                // at this point, children have not yet been added, release and let widget complete workflow
                var acc_container = this;
                setTimeout(function() {
                   // get the child, then hack to get its wrapper (includes titlenode)
                   var hiddenChild = acc_container.getChildren()[0].id+"_wrapper"
                   hiddenChild = dijit.byId(hiddenChild);
                   acc_container._hideChild(hiddenChild);
               }, 100);
            </script>

         <div dojoType="dijit.layout.ContentPane" dojoProps="selected:true" selected="true">
          </div>