[RSS]
Creating Ordinal Columns in Table Component



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}

Attachments

123.png Info on 123.png 149412 bytes