Hide and unhide button objects

 9 Replies
 0 Subscribed to this topic
 12 Subscribed to this forum
Sort:
Author
Messages
Deborah Creek
Basic Member
Posts: 10
Basic Member
I am working on version 9.0.1.4 and a change to the look and feel of buttons from previous versions if causing a problem for me.  I would like to use javascript code to hide and unhide buttons.  In previous versions I was able to use setFormValue to change the button text to either be blank (hide) or contain writing (unhide) as needed and since the button was displayed as a link this made the object disappear.  Now that the button displays regardless of the text I need a way to truly hide the button.  I was hoping that setting style.visible = “hidden” or style.display = “none” would work but I had no luck. 
 


John Henley
Posts: 3359
See if you can use the style.visibility (note the spelling...)

Here are two methods I use:

var objToolBarBtn = lawForm.UIDocument.getElementById("xxx");
if (objToolBarBtn) {
objToolBarBtn.style.visibility="hidden";
}

var objToolBarBtn = lawForm.UIDocument.getElementById("xxx");
if (objToolBarBtn) {
objToolBarBtn.style.visibility="visible";
}

lawForm.getFormElement("label8").style.visibility = "hidden"
lawForm.getFormElement("label8").style.visibility = "visible"
Thanks for using the LawsonGuru.com forums!
John
Deborah Creek
Basic Member
Posts: 10
Basic Member
Thanks for the fast reply! This is the syntax I was trying (had a typo in my original post, oops)

lawForm.getFormElement("push31").style.visibility = "hidden"

It does hide labels and text but for a button in 9.0.1 the text/name of the button hides but the empty box of the button is still visible. I'm trying to make the button disappear entirely.
Deleted User
New Member
Posts: 0
New Member
Unfortunately in 9.0 hiding buttons doesn't work anymore.  You have to either disable them instead or remove the button from the form and dynamically add/delete them in the OnInit and OnAfterTransaction functions using javascript.
Deborah Creek
Basic Member
Posts: 10
Basic Member
Thanks Gary! Could you possibly show me an example of how you would delete/add in javascript? I will put it in OnAfterTransaction and it will be perfect! (at least I envision it will be...)
Tim Cochrane
Veteran Member
Posts: 154
Veteran Member
I would also like to see an example of how to dynamically add/delete buttons in DS. I'm working on a project that could use that functionality
Tim Cochrane - Principal LM/IPA Consultant
Tim Cochrane
Veteran Member
Posts: 154
Veteran Member
Any update on dynamically add/delete for buttons?
Tim Cochrane - Principal LM/IPA Consultant
John Henley
Posts: 3359
The button is wrapped in a div; try:
lawForm.getFormElement("push31").parent.style.visibility = "hidden"
Thanks for using the LawsonGuru.com forums!
John
Deborah Creek
Basic Member
Posts: 10
Basic Member

The parent.style.visibility solution does not work either.

I have also found a challenge hiding a listbox.  If I set visibility to hidden it hides the textbox but does not hide the icon with the drop down arrow.

Any ideas?

Steven Gray
Advanced Member
Posts: 21
Advanced Member

Try this. I was able to hide the button in 9.0 using this method:

function FORM_OnAfterFrameworkInit()
{  
      var objButton = lawForm.getFormElement("push2");
      if (objButton)
      {
        objButton.value="";
      }
}


function FORM_OnAfterTransaction(data)
{
      var objButton = lawForm.getFormElement("push2");
      if (objButton)
      {
        if( // test for show-no-show condition here )
        {
              objButton.value="ShowTheButton";
          }
          else
          {
              objButton.value="";       
          }
      }
}


The properties:
value="" will hide the entire button,
visibility="hidden" will gray-out the button, but no text shows.