Table Column Generator (Typed)
Result:
Only code that dynamically generates the generated column at runtime is generated.
public class GeneratedColumn implements ColumnGenerator { @Override public Object generateCell(Table table, Object itemId, Object columnId) { Products bean = getBean(table, itemId); // insert your code here and return the calculated value return bean.toString(); } @SuppressWarnings("unchecked") public Products getBean(Table table, Object itemId) { return ((XdevTable<Products>) table).getContainerDataSource().getItem(itemId).getBean(); } }
The code file is displayed in the Project Management > User Interface (or in the package you select), and can be edited by making a selection in the code editor.
Add own code
- In the Project Management > User Interface > select the generated code file GeneratedColumn.
In the following code view, enter a calculation in the line with the following comment // insert your code here .... The result is returned with return.
// insert your code here and return the calculated value BigDecimal unitPrice = bean.getUnitprice(); BigDecimal salesTax = new BigDecimal(7.5); BigDecimal totalPrice = unitPrice.multiply(salesTax).divide(new BigDecimal(100)); return totalPrice;
- Click Save.
Read values from the current row
With the automatically generated variable bean, you can read the individual values of the row.
Generated code:
@Override public Object generateCell(Table table, Object itemId, Object columnId) { Products bean = getBean(table, itemId); // insert your code here and return the calculated value return bean.toString(); }
Example 1:
String productName = bean.getProductname();
Example 2:
Integer productID = bean.getProductid();
Example 3:
BigDecimal unitPrice = bean.getUnitprice();
Examples:
Column linking
@Override public Object generateCell(Table table, Object itemId, Object columnId) { Products bean = getBean(table, itemId); // insert your code here and return the calculated value String productName = bean.getProductname(); Categories category = bean.getCategories(); BigDecimal unitprice = bean.getUnitprice(); return productName + " " + category + " " + unitprice; }
- Next
XDEV Software Corp. - One Embarcadero Center, San Francisco, CA 94111, US
Copyright © 2015. XDEV Software Corp. All rights reserved.