java - Adding person.city.name to a TableView -
i have tableview , pojos , want bind property 1 of them tableview.
however, property pojo , should 1 property show in tableview.
here's code:
<tableview fx:id="listadeudores" layoutx="85.0" layouty="7.0" prefheight="200.0" prefwidth="200.0"> <columns> <tablecolumn prefwidth="75.0" text="archivo"> <cellvaluefactory> <propertyvaluefactory property="archivo" /> </cellvaluefactory> <cellfactory> <formattedtablecellfactory alignment="center" /> </cellfactory> </tablecolumn> <tablecolumn prefwidth="299.0" text="nombres"> <cellvaluefactory> <propertyvaluefactory property="nombres" /> </cellvaluefactory> <cellfactory> <formattedtablecellfactory alignment="center" /> </cellfactory> </tablecolumn> <tablecolumn minwidth="0.0" prefwidth="95.0" text="actual" > <cellvaluefactory> <propertyvaluefactory property="deuda.saldo" /> </cellvaluefactory> <cellfactory> <formattedtablecellfactory alignment="center" /> </cellfactory> </tablecolumn> <tablecolumn prefwidth="75.0" text="nueva" /> <tablecolumn prefwidth="75.0" text="parcial" /> </columns> </tableview>` and persona , deuda classes:
public class persona { private integer id; private integer archivo; private string nombres; private list<recibo> recibos; private deuda deuda; } public class deuda { private date fecha; private bigdecimal saldo; private bigdecimal nuevo; private bigdecimal descuento; } i want set person.deuda.saldo in fxml file, used:
<tablecolumn minwidth="0.0" prefwidth="95.0" text="actual" > <cellvaluefactory> <propertyvaluefactory property="deuda.saldo" /> </cellvaluefactory> <cellfactory> <formattedtablecellfactory alignment="center" /> </cellfactory> </tablecolumn> but won't render in tableview. how can prepare this?
you can't utilize propertyvaluefactory this: need implement callback directly.
put fx:id="actualcolumn" on table column, inject column controller with
@fxml private tablecolumn<persona, bigdecimal> actualcolumn ; and in controller's initialize() method, do:
actualcolumn.setcellvaluefactory(celldata -> new readonlyobjectwrapper<bigdecimal>(celldata.getvalue().getdeuda().getsaldo())); java data-binding javafx tableview fxml
No comments:
Post a Comment