Adding a column with row numbers

Question

Rows in a table need to be enumerated by order, but the table does not contain a column with a row's number. Is there a way to achieve this?

 

Answer

  1. Add a new field in the table. In the screenshot below it is named Item Number:


  2. In the properties of the newly created field, create a script rule. Make sure the field is not read-only in the script properties: 

  3. The code of the rule is as follows:
for (int i = 0; i < Context.Field("Invoice_Table").Items.Count; i++)
{
   Context.Field("ItemNumber").Items[i].Text = (i+1).ToString();
}

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.