Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Deleting rows in a table with a button

Avatar

Level 5

Good Day All;

I seemed to have run into a snag with trying to add a delete button in a table that will delete a row. Let me expain.

The form has 1 table that has 7 cells made up of text fields and drop downs. This table is in its own subform.

There is a button to add rows as the user requires. The code I am using to add rows: psl_list_subform.instanceManager.addInstance(1);

I have been asked to add a delete button so a user can delete rows. I have added this to the end of the table. SO each time a row gets repeated, there is a delete button. The code I am “trying” to use is;

Table4.Row1.instanceManager.removeInstance(this.parent.index);

When I click on the button to delete, nothing happens. I brought up the JavaScript debugger, there are no errors.

Any ideas what I missed.

Thanks All

Chomp

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

from my understanding of your form, you adding new instances of the subform "psl_list_subform" which contains a single table row.

The hierarchy that will look like "psl_list_subform.Table4.Row1.RemoveButton".

To remove an instance of the subform, from a button within the table row the script needs to refer to the 3rd parent of the remove button.

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

Explaination: this = RemoveButton, 1st parent = Row1, 2nd parent = Table4, 3rd parent = psl_list_subform

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Hi,

from my understanding of your form, you adding new instances of the subform "psl_list_subform" which contains a single table row.

The hierarchy that will look like "psl_list_subform.Table4.Row1.RemoveButton".

To remove an instance of the subform, from a button within the table row the script needs to refer to the 3rd parent of the remove button.

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

Explaination: this = RemoveButton, 1st parent = Row1, 2nd parent = Table4, 3rd parent = psl_list_subform

Avatar

Level 5

Thanks you radzmar. Worked like a charm.

I did not take the hierarchy into account. This is something I will have to keep in mind.

Thanks Again

Chomp