cornercorner
FeaturesPluginsDocs & SupportCommunityPartners

Add Ordinal Columns

Creating Ordinal Columns in Table Component


File:123_Add_Ordinal_Columns.png


1. Solution 1:

- Right-click the table > Table Layout
- Add a new column named "No." and then set its value to #{currentRow.tableRow.rowId + 1}

  • The bean currentRow indicates one row (one record). Its type is TableDataProvider
  • The property tableRow has type RowKey with an auto increment attribute rowId
  • Cons: the order is changed if we sort any columns

2. Solution 2:

- Create a private property "no" in the page that contains the table
- Write a method "getNo"as below:

private int no = 0;

public int getNo() { return no++; }

- Bind value of no. column to this getter #{no}