Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

add instance before existing instance

Avatar

Level 2

Hello all,

is there a way to add a new instance of a Subform to show in a top the existing subform? the way it works now when you add a click on button to add a subform, the new subform shows under the exisitng subform and so forth, every time I add a subform it goes to the bottom. I want the opposite to happen where new subforms, always show in the top of old subforms.

1 Accepted Solution

Avatar

Correct answer by
Level 7

It depends on where you want the subform to actually go.

Suppose you have a button inside a subform and you always want the new subform to go on top of the entire stack of subforms:


this.parent.instanceManager.insertInstance(0);


If you want to add it right above whatever instance you're working on, then this code will work:


this.parent.instanceManager.insertInstance(this.parent.index);


Note: You'll need to add or remove reference points depending on what you're using to trigger the event, of course.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 7

It depends on where you want the subform to actually go.

Suppose you have a button inside a subform and you always want the new subform to go on top of the entire stack of subforms:


this.parent.instanceManager.insertInstance(0);


If you want to add it right above whatever instance you're working on, then this code will work:


this.parent.instanceManager.insertInstance(this.parent.index);


Note: You'll need to add or remove reference points depending on what you're using to trigger the event, of course.

Avatar

Level 2

Fantastic... it worked ..excellent..thank you very much