问题
I have an app that uses a dijit.layout.AccordionContainer
with two child containers.
When the map is loaded, one of the containers is open by default. I would like the default container to close and the second container to open when a button is clicked. Any idea how to do this?
I have tried using the selectChild()
method but must be doing it wrong or am I completely off base?
EDIT My HTML is:
<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>
where I am trying to open "tab2" on click via a function I have created for some other things I need to happen on click
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);
}
回答1:
It sounds like you are on the right track trying to using the AccordionContainer#selectChild
method. This should be easy to handle by setting your Button's onClick
handler as follows:
onClick: function(){
var container = dijit.byId("container");
container.selectChild("pane2", true);
}
Where "pane2
" is the id of the ContentPane that you want to open on button click, and true
indicates that you want the opening of the pane to be animated. You can see an example in this fiddle.
来源:https://stackoverflow.com/questions/15095893/how-to-switch-an-accordioncontainer-on-click