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:
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:
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.
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).