Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

Script to remove all rows in a table except the first

Avatar

Level 5

Please see the screenshots for the question/radio button I'm scripting.  If "No" is clicked I would like it to delete all rows except the first one.  So if the user first clicks Yes, adds a bunch of rows and then clicks No, I want all the extra rows to be deleted.  I'm using the script below but it only deletes half of the rows at a time.  I have to click No 2-3 times to delete all the rows.  Greatly appreciate any help!

// remove extra rows that may have been added

var rowCount = Page2.UserList.Table1._RowUserName.count;

for (var i=0; i<rowCount; i++) {

  Page2.UserList.Table1._RowUserName.removeInstance(i);

}

LCD1.png

lCD2.png

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi there,

you can directly use the setInstances method of the instanceManager like the following :

Hope this will help you!

View solution in original post

0 Replies

Avatar

Correct answer by
Level 10

Hi there,

you can directly use the setInstances method of the instanceManager like the following :

Hope this will help you!

Avatar

Level 5

That worked like a charm!  That's what happens when you learn to script through the school of hard knocks, just fumbling your way through it -- I just had to teach myself javascript, so I never discovered this function before.  Really appreciate the help.

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now