2013-02-26 78 views
0

我有一個使用dijit.layout.AccordionContainer和兩個「子容器」的應用程序如何在點擊時切換AccordionPane?

當地圖加載時,其中一個容器默認打開。我希望默認容器關閉,點擊按鈕時打開第二個容器。任何想法如何做到這一點?

我已經嘗試使用selectChild()方法,但必須做它錯誤或完全離開基地。

編輯 我的HTML是:

<div dojotype="dijit.layout.ContentPane" id="leftPane" region="left" splitter="true"> 
     <div dojotype="dijit.layout.AccordionContainer"> 
     <div dojotype="dijit.layout.ContentPane" title="Table of Contents"> 
         <div id="tocDiv"> 
         </div> 
        </div> 
        <div dojotype="dijit.layout.ContentPane" title="Search Results" id="tab2"> 
               <div id="datagrid"> 
               <table data-dojo-type="dojox.grid.DataGrid" data-dojo-id="grid" id="grid" data-dojo-props="rowsPerPage:'5', rowSelector:'20px'"> 
              <thead> 
               <tr> 
                <th field="Parcel Identification Number" width="25%"> 
          Parcel ID 
                </th> 
                <th field="Site Address" width="30%"> 
          Address 
                </th> 
               </tr> 
              </thead> 
             </table> 
             </div> 
        </div> 
     </div> 
     </div> 

在那裏我想通過我已經爲一些其他的事情,我需要在點擊發生創建一個函數打開「TAB2」上點擊

JS:

function doFind() {    
     //Set the search text to the value in the box 
     findParams.searchText = dojo.byId("parcel").value; 
       grid.showMessage("Loading..."); //Shows the Loading Message until search results are returned. 
     findTask.execute(findParams,showResults); 
     } 
+0

這種純粹的JavaScript/Dojo問題更適合於Stackoverflow,而不是Gis.Stackexchange。 – 2013-02-27 02:56:17

回答

3

你相當接近。

我假設你正在聽你自己的按鈕點擊事件。如果你不願意的話,請把這段代碼貼出來。

如果是這樣,那麼你需要做的:

<accordian-container>.selectChild(<pane to open>); 

您需要將面板傳遞給selectChild方法。

手風琴容器是一種堆容器因此這份文檔應該有所幫助:

http://dojotoolkit.org/reference-guide/1.8/dijit/layout/StackContainer.html

這裏是幾乎同樣的問題的鏈接#2:Whats the best way to programatically open a pane inside Dijit AccordionContainer

+0

謝謝。我編輯了我的問題以顯示我正在使用的代碼。 – Craig 2013-02-26 18:49:51