0

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

<!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>​
4

1 回答 1

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>
于 2012-05-04T16:51:51.253 回答