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

How to create Rows dynamically from Code without binding

Avatar

Level 2

Dear All,

I have few fields in my Form which comes as below.

field a = test1|test2|test3

now i have splitted that with " | " but i when i try to add that in table only first line shows up.

 

 

Code :

var prBatchTable = prBatch.formattedValue.split("|");

if (prBatchTable[0] != "") {
for (i = 0; i < prBatchTable.length; i++) {
curRow = this.resolveNode("Row1[" + i + "]");
curRow.Cell3.rawValue = parsednew;
}
}

 

/// Also tried manully doing the loop

curRow = this.resolveNode("Row1[" + 0 + "]");
curRow.Cell3.rawValue = "11";

 

curRow1 = this.resolveNode("Row1[" + 1 + "]");

curRow1.Cell3.rawValue = "22";

 

How can i create multiple instance of Row1?

 

Dynamic table.PNG

1 Reply

Avatar

Level 10

Hi,

 

you need to set the number of instances of the row depending on your input.

 

var aBatchTable = prBatch.formattedValue.split("|"),
    oRows;
// Set instances of rows
Table1._Row1.setInstances(aBatchTable.length);
// Resolve all rows into a node list
oRows = Table1.resolveNodes('Row1[*]');
// update value in every row
aBatchTable.forEach(function (element, index) {
    oRows.item(index).Cell3.rawValue = element;
});

 

The ultimate experience is back.

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

Register Now