• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Hide/Show Widgets from script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hide/Show Widgets from script

    Is it possible to show/hide a widget from a custom script?

    let form = getWidget('theForm');
    form.someProperty? = someValue?;
    success();


  • #2
    Yes.
    Code:
    myWidget.show();
    myWidget.hide();
    In the next update, you will be able to do this by setting an app variable.

    Comment


    • #3
      Well that's easy :p
      Thanks!!

      Comment


      • #4
        This works OK for a regular form, but I'm having issues with a pop-up form.
        The hide() seems to clear out the form, but leaves the container(s):

        img1.png

        img2.png

        Comment


        • #5
          Here is an example script that will check if the widget is in a popup or not and act accordingly.

          hideShowWidget takes two parameters
          • widget
          • action - hide/show

          Code:
          var myWidget       = getWidget('myChart'),
              hideShowWidget = function (wdg, action) {
                  var popupContainer = wdg.up('widget-popup'),
                      livesInPopup   = (!Valence.isEmpty(popupContainer)) ? true : false,
                      actOn          = (livesInPopup) ? popupContainer : wdg;
          
                  if (!Valence.isEmpty(actOn[action]) && typeof actOn[action] === 'function') {
                      actOn[action]();
                  }
              };
          
          hideShowWidget(myWidget, 'hide');

          Comment

          Working...
          X