Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Add/Delete row

Avatar

Former Community Member

Hello,

How can add a new row directly after the current row not at the end of the form?

For example: User fills the question/answer form and they want to add new row(s) to ones that already added. Suppose that they are at question 1, 2, 3 but realize that they want to add a new row between row#1 & 2 or row# 2 & 3 which can re-number to reflect the new row to the right number instead of at the end after row#3.

Can any one please advise.

Thanks,

Han

3 Replies

Avatar

Level 10

Hi Han,

Check out this example: http://assure.ly/gk8Q7a.

In particular Tables 5 (uses Tables) and 6 (uses Subforms). Basically I have set up the index cell as a button. When clicked it will "add" a new row directly underneath the row clicked.

The script is in fact doing two things, one directly after the other.

  1. It adds a new row at the end of the table, and
  2. Then it moves that new row based on the index of that new instance.

Does that make sense?

Niall

Avatar

Former Community Member

You will need to do it in two steps .....addrow will add the row to the end of the rows, then you can use a moveInstance to move it to the location that you want.

Paul

Avatar

Former Community Member

Thanks to Naill and Paul. It works nicely as expected.

Han Dao