Expand my Community achievements bar.

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;
});