Expand my Community achievements bar.

SOLVED

Presence of buttons in subform due to their position

Avatar

Level 1

Hi guys,

 

I got a task to build a Form with a subform. By clicking a button ("add" or "+") another subform of the same kind is created underneath and one button that removes the subform in wich it is placed (via removeInstance(this.parent.index)). That works pretty well. Now I am supposed to move the subform up and down with one button for each:

mojo0220_0-1607591016143.png

This too works. But the next task doesn't work. According to the position of the subform, the moving buttons are a) both there (for subform 2 to max-1), b) only move down (subform 1) and c) only move up (for subform max). After they are moved it should check again every subforms position and according to that position it shall hide a button (if it is moved to first or last position) or show them again (if moved from first or last position).

 

Here are some information on the names of subforms etc. and a first attempt by myself:

mojo0220_1-1607591363327.png

mojo0220_2-1607591392723.png

With this code the "move up" button of the first subform is hidden after opening the doc but after moving it down the "move up" button won't appear again. 

 

I am quite clueless about what to do so maybe one of you can help me with that.

Thank you!

 

1 Accepted Solution

Avatar

Correct answer by
Employee

Looking at your screenshots I think that the fact that you have this in the initialize event of the button may be the reason for it to fail. Initialize only triggers at the beginning or after re-layout and some other things but not when you click on a button. Add this to the click event where you have the logic for move. If you also need to run it on forms initialization then create a script object, add a function like buttonVisibility() and call that in the initialize as well as the click event (saves you duplicate code).

View solution in original post

1 Reply

Avatar

Correct answer by
Employee

Looking at your screenshots I think that the fact that you have this in the initialize event of the button may be the reason for it to fail. Initialize only triggers at the beginning or after re-layout and some other things but not when you click on a button. Add this to the click event where you have the logic for move. If you also need to run it on forms initialization then create a script object, add a function like buttonVisibility() and call that in the initialize as well as the click event (saves you duplicate code).