Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Numbering Table Rows as they are added.

Avatar

Former Community Member
First I must admit to the fact that a novice could be my teacher :>) .

I have the following table as an example:

------------------------------------------------

| | | Spanned Col Header | | |

| Col1 | Col2 | Col3 | Col4 | Col5 | Col6 |

------------------------------------------------

| 1 | | | | | |

------------------------------------------------

| 2 | | | | | |

------------------------------------------------

-----------

|Add Row Btn|

-----------



I am trying to number each row in a dynamic table as it is added by clicking on the Add Row Btn.



I have the following script in the DetailPage.sfTable.itemTable.Row::initialize - (JavaScript, client) event.



var rowCount = new Number(sfMain.startvalue.rawValue);

rowCount = rowCount + 1;

sfMain.startvalue.rawValue = rowCount;

itemTable.Row.itemNumber.rawValue = rowCount;



This seems like it should work and it does . . . kind of. It increments as expected (1,2,...) but when I write to the cell in the row it changes all entries in Col1 to the same value.



The cell at a1 is defined:

Cell Type: Numeric Field

Value Type: Calculated Read Only

Default Binding: $record.itemTableRow[*]

Data format: Integer
0 Replies