Expand my Community achievements bar.

SOLVED

How to hide objects in subsequent floating forms

Avatar

Former Community Member

Hello,

I have a subform which has an 'Add' button.  When user clicks on the add button, a new subform is added.  I, however, don't want to show this 'Add' button in the subsequent forms.  I want to show it in the 1st form only.  Also, the user can only add max 3 forms.  Thus, as the form number reaches 3, I want to disable/hide the 'Add' button.

Is there a way to do that?  Could someone show me how?

Thanks in advance for your help.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

For the first part, the easiest way would be to take the button out of the repeating subform. Maybe place it just above the subform. Then it will not appear in other instances. You could include script in the initialize event, but this would not be the preferred route. Se how you get on with the button out of the subform and if you end up needing the script come back to us.

To disable the button, you will need script in the layout:ready event of the button. This is not the most efficient, because the layout:ready event fires so often (see here http://assure.ly/nB0Bvz). If your form is not too lengthy then you mightn't notice too much of a performance hit.

So, if your repeating subform is called myRepeatingSubform, the following in the layout:ready event of the button should get you close:

if (_myRepeatingSubform.count >= 3) {

     this.presence = "invisible";

}

else {

     this.presence = "visible";

}

Hope that helps,

Niall

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

For the first part, the easiest way would be to take the button out of the repeating subform. Maybe place it just above the subform. Then it will not appear in other instances. You could include script in the initialize event, but this would not be the preferred route. Se how you get on with the button out of the subform and if you end up needing the script come back to us.

To disable the button, you will need script in the layout:ready event of the button. This is not the most efficient, because the layout:ready event fires so often (see here http://assure.ly/nB0Bvz). If your form is not too lengthy then you mightn't notice too much of a performance hit.

So, if your repeating subform is called myRepeatingSubform, the following in the layout:ready event of the button should get you close:

if (_myRepeatingSubform.count >= 3) {

     this.presence = "invisible";

}

else {

     this.presence = "visible";

}

Hope that helps,

Niall

Avatar

Former Community Member

Thank, Niall.  I actually figured that out after I posted the question.