Table

A org.uqbar.arena.widgets.tables.Table[R] shows a table / grid with a list of elements of type R.

Bindings

A table must

  • have at least one column
  • bind its property items against a collection of elements that match R type

Another properties

  • It inherits the following properties from Control:
    • enabled, visible & background (bindables)
    • height property has no effect, you should use numberVisibleRows instead
    • width property has no effect, you should use fixedWidth for every column
  • And also inherits from Skinnable Control this properties:
    • fontSize, foreground, background
  • value (optional): type R - bind the selected element

Example

A Table that shows a collection of customers in a Cell Phone company:

// Xtend
val table = new Table<Customer>(mainPanel, typeof(Customer)) => [
    items <=> "results"
    value <=> "selectedCustomer"
]

// Java
Table<Customer> table = new Table<Celular>(mainPanel, Customer.class);
table.bindItemsToProperty("results");
table.bindValueToProperty("selectedCustomer");

Note the parallel relation between Table and Column models: the table has a customer list as a model, whereas every column has a customer as a model.

And this is how we add a column with the name of every customer:

// Xtend
new Column<Customer>(table) => [
    title = "Name"
    fixedSize = 200
    bindContentsToProperty("fullName")
]

// Java
new Column<Celular>(table) //
    .setTitle("Name")
    .setFixedSize(250)
    .bindContentsToProperty("fullName");

A Customer has a String property fullName.

You can align a column by using alignLeft() -default-, alignCenter() or alignRight() messages.

// Xtend
new Column<Customer>(table) => [
    title = "Amount"
    alignRight
    bindContentsToProperty("amount")
]

// Java
new Column<Celular>(table) //
    .setTitle("Amount")
    .alignRight()
    .bindContentsToProperty("amount");

If you want to adapt a property you can

  • use a transformer
  • define a read-only property (eg: getXXX() method in the model)