Select to view content in your preferred language

How to change WAB widget window size?

13524
23
08-23-2016 07:55 AM
DanielChantlos1
Regular 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
AdrianWelsh
MVP Honored Contributor
0 Kudos
DanielChantlos1
Regular Contributor

I looked in the OnScreenWidgetPanel.js file and do not see these lines of code inside.

Am I missing something? Also, I am hoping to set different sizes for different widgets.

0 Kudos
MichaelRobb
Honored Contributor

For WABde 2.0 you would go to the widget of interest.

For example, for the About Widget...

[app#]\widgets\About\css\style.css

RobertScheitlin__GISP
MVP Emeritus

Daniel,

  Another way to do it (other than Robb's way). If you want to resize a specific widget in the Launchpad theme then I would add this code to the startup function in that specific widgets Widget.js:

        var panel = this.getPanel();
        var pos = panel.position;
        pos.width = 600;
        panel.setPosition(pos);
        panel.panelManager.normalizePanel(panel);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
DanielChantlos1
Regular Contributor

This may be a simple question, but what lines do you place this in the startup function?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Daniel,

  It does not really matter. I placed it right before the end of the function.

0 Kudos
PhilLarkin1
Frequent Contributor

I gave your code a try. It works pretty well. However, if a user is to use the resize handle the widget size will default to width:400 height:400. The resize handle will not allow any size smaller than 400 after that. (400 is an estimate. The widget is reset to whatever the default is.)

 

Any ideas on how to overcome this issue? I might just remove the ability to resize as shown in your example here: disable/hide  resize handle for Widget  

 

Also, ESRI should probably be supplementing your salary. Thanks for all of your hard work on the forums. You have helped many people! 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Phil,

   Nice catch. Here is the modified code to correct that issue:

var panel = this.getPanel();
panel.position.width = 600;
panel.setPosition(panel.position);
panel.panelManager.normalizePanel(panel);
RobertScheitlin__GISP
MVP Emeritus

All,

   Better yet, because the widget will revert to normal size once closed and reopened, you should just add a new onOpen function and not use the startup addition suggested earlier:

      onOpen(){
        var panel = this.getPanel();
        panel.position.width = 600;
        panel.setPosition(panel.position);
        panel.panelManager.normalizePanel(panel);
      },