How to change WAB widget window size?

12478
23
08-23-2016 07:55 AM
DanielChantlos1
Occasional Contributor

Is there a way I can modify code in WAB Developer Edition to change the size of the widget window for specific widgets in LaunchPad theme? I am using WAB Developer Edition 2.1

0 Kudos
23 Replies
PhilLarkin1
Occasional Contributor III

I have tried both suggestions: placing latest code in startup and onOpen functions. Neither overcome the resize handle issue. I'm testing this on WAB 2.1 with Chrome and IE 10. 

I'm curious if danielchantlos has experienced the same thing. Anyone else? 

This is what my onOpen function looks like (in Widget.js):

      onOpen: function () {

        var panel = this.getPanel();
        panel.position.width = 300;
        panel.position.height = 300;
        panel.setPosition(panel.position);
        panel.panelManager.normalizePanel(panel);

        console.log('onOpen');
      },‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
DanielChantlos1
Occasional Contributor

Phil,

I just copy/pasted your code into my Widget.js as is after the Startup function, and I have no resize/reverting issue. In fact, this is exactly what I was looking for!

Thank you Robert and Phil!

0 Kudos
PhilLarkin1
Occasional Contributor III

Nice! I'm glad that is working for you. There must be something else going with my code. I think I'll disable the resize handle for now. Thanks for both of your help. 


Here is what I am experiencing if anyone is curious: 

link: Imgur 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Phil,

   I did not test making the widget smaller then the default original size for that you will have to have this in the startup function:

        var panel = this.getPanel();
        panel.position.width = 300;
        panel.position.height = 300;
        panel._originalBox = {
          w: panel.position.width,
          h: panel.position.height,
          l: panel.position.left || 0,
          t: panel.position.top || 0
        };
        panel.setPosition(panel.position);
        panel.panelManager.normalizePanel(panel);

and the onOpen function just the way you have it.

PhilLarkin1
Occasional Contributor III

Robert you are the guru. Thank you. Your latest suggestion is working. 

I added this to onOpen and I'm not seeing any issues. So, I only have panel resize code in onOpen, not in startup. Do you anticipate that this would be a problem? Seems fine in testing. 

Where is the documentation for getPanel()/setPosition()/normalizePanel()? I can't find anything from dojo or esri.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Phil,

   No there should be no issue if it is working for you. The getPanel function is supported by all WAB widgets (thought that one was documented). But the others setPosition and normalizePanel are specific functions of the Launchpad panel (internal functions and not documented).

0 Kudos
PhilLarkin1
Occasional Contributor III

Here is the only documentation related mention of getPanel() I can find: Communication to app container—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers 

RobertScheitlin__GISP
MVP Emeritus

yep that is what I was thinking of.

0 Kudos
MattReeves
New Contributor III

Hi Robert,

I am wondering why this code doesn't work when added to the Elevation Profile widget that you wrote. Does something else need to be changed to make this work in that widget?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Matt,

   What is not working? I just tested in WAB 2.8 Launchpad adding this to the onOpen of the Elevation Profile widget.

        var panel = this.getPanel();
        var pos = panel.position;
        pos.width = 720;
        panel.setPosition(pos);
        panel.panelManager.normalizePanel(panel);
0 Kudos