Expand my Community achievements bar.

SOLVED

Automatically creating table references alphabetically

Avatar

Level 2

Hi,

I'm creating a table where the first column in a row is automatically numbered. When a 'row' new instance is created (using Action Builder in ES2) the first cell in the table should automatically ascend.

I've figured out how to do this with numbers - (this.rawValue = (this.parent.index + 1);) but i have a table where i want to use letters of the alphabet instead. (I.e. A,B,C etc.) Is this possible?

If it helps, the maximum amount of rows in the table is 4. (D)

Cheers


Rob

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Rob,

On the right track. If you create an array with the alphabet, then the script would access the appropriate letter, depending on the row number.

Sample here: https://acrobat.com/#d=Zk2XWWDUWNfG*VuRTNy5QQ

Also the script is in the layout:ready event, so that if rows are deleted, all indices will be updated.

Good luck,

Niall

View solution in original post

6 Replies

Avatar

Correct answer by
Level 10

Hi Rob,

On the right track. If you create an array with the alphabet, then the script would access the appropriate letter, depending on the row number.

Sample here: https://acrobat.com/#d=Zk2XWWDUWNfG*VuRTNy5QQ

Also the script is in the layout:ready event, so that if rows are deleted, all indices will be updated.

Good luck,

Niall

Avatar

Level 2

Awesome! Exactly what i needed.

Thanks a lot.

Rob

Avatar

Level 4

>  (this.rawValue = (this.parent.index + 1);)

this.parent.index + 1  will yield the same result.  No need for the rawValue assignment.

Avatar

Level 10

Hi Iakov,

I agree this.parent.index + 1 will work in a calculate event, but in this case the calculation will not automatically update when a row is deleted.

When used in the layout:ready event you need to give the full calculation $ = this.parent.index + 1 (FormCalc) or this.rawValue = this.parent.index + 1; (JavaScript).

In both cases this will give a numbered index that will update in real time as rows are added and deleted. The use of this approach also helps when using buttons to move rows up and down the table.

The script in the example was a little more involved because we were using the index value to access an array.

Thanks,

Niall