Select to view content in your preferred language

Collapse widgest (didgits) on startup

4314
10
02-12-2013 10:05 AM
JimWharton
Occasional Contributor
I have a few widgets that I'm using. (Measure tool and layers widget) These are both collapse-able but I'd like them to start closed. As useful as the measurement tool is, it's only used about 4% of the time so it would be great if I could load the map with it closed.

Is this possible?

Thanks,
-Jim
0 Kudos
10 Replies
SteveCole
Honored Contributor
I haven't used either of the widgets you reference but you should be able to. In your map initialization function, try adding something like:

dijit.byId('Your Measurement Widgit ID here').hide();


Another possibility could be adding a parameter on the HTML side of things. In one of my apps, I'm using a standard dijit TitlePane which defaults to an expanded state. In my HTML, I added open="false" into the line and it now loads closed by default:

<div data-dojo-type="dijit/TitlePane" id="layersList" title="<b>Show Me...</b>" open="false">


Good luck!
Steve
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Jim,

I've encountered some problems with setting the 'open' parameter to false.  The dijit/TitlePane would still open.  Instead, I've had to use '0'.  Ex:

Did not work:
<div id="titlePane" data-dojo-type="dijit.TitlePane" data-dojo-props="title:'Measurement', open:'false'">


Worked:
<div id="titlePane" data-dojo-type="dijit.TitlePane" data-dojo-props="title:'Measurement', open:0">
JeffJacobson
Frequent Contributor
Hi Jim,

I've encountered some problems with setting the 'open' parameter to false.  The dijit/TitlePane would still open.  Instead, I've had to use '0'.  Ex:

Did not work:
<div id="titlePane" data-dojo-type="dijit.TitlePane" data-dojo-props="title:'Measurement', open:'false'">


Worked:
<div id="titlePane" data-dojo-type="dijit.TitlePane" data-dojo-props="title:'Measurement', open:0">


Have you tried removing the single quotes around 'false'? I don't have any experience with this dijit, but when JavaScript converts the string 'false' to a boolean it becomes true.
JimWharton
Occasional Contributor
Have you tried removing the single quotes around 'false'? I don't have any experience with this dijit, but when JavaScript converts the string 'false' to a boolean it becomes true.


I naturally just used a javascript false without the quotes. It never occurred to me to try it WITH quotes. I'll try it with 0 though.
0 Kudos
JimWharton
Occasional Contributor
Nope, finally got a chance to try all options.

false, 0 and null have no effect. Looks like ESRI want those widgets open when the page loads. Absolutely horrible for screen real-estate.

For now, I've triggered a click on their titlePanes. But man, that's one bloody ugly hack.

Thanks for the suggestions!

-Jim
0 Kudos
AdrianMarsden
Honored Contributor
I've not had an issue - here's my code for a collapsed at start bottom pane

        <div dojotype="dojox.layout.ExpandoPane"
            splitter="true"
            duration="125"
            region="bottom"
            title=""
            startexpanded="false"
            id="footer"
            maxwidth="275"
            style="height: 150px;">


            <div id='xxx' class='ref'></div>
        </div>
0 Kudos
JimWharton
Occasional Contributor
I've not had an issue - here's my code for a collapsed at start bottom pane

        <div dojotype="dojox.layout.ExpandoPane"
            splitter="true"
            duration="125"
            region="bottom"
            title=""
            startexpanded="false"
            id="footer"
            maxwidth="275"
            style="height: 150px;">


            <div id='xxx' class='ref'></div>
        </div>


Two things of note. 1. You're specifying attributes on the DOM node itself. (a Dojo Expandopane). 2. You're using the key 'startexpanded' (not 'open'). In the docs for the measurement widget/dijit, I'm not sure this is noted as a property.

So if I can use 'startexpanded' in JS while defining the widget, then great. Even using this method is better than what I'm currently doing. But It does turn my markup into tag soup just like code from 1999. (Most dojo code tends to do that though)
0 Kudos
AdrianMarsden
Honored Contributor
😄  There are some benefits in being an untrained hack - I never notice if I have a horrid mixture - you should see some of the javascript/.asp pages I have done in the past - a total mix of syntax.

I can remember having issues over this, but can't recall the specifics, it was a long time ag (well last year sometime)
0 Kudos
JimWharton
Occasional Contributor
😄  There are some benefits in being an untrained hack - I never notice if I have a horrid mixture - you should see some of the javascript/.asp pages I have done in the past - a total mix of syntax.

I can remember having issues over this, but can't recall the specifics, it was a long time ag (well last year sometime)


Ha! I've found that when using this framework, "untrained hackiness" is a valuable asset.

Thanks for your input on it, I'll probably use your method.

-Jim
0 Kudos