In a Browse-View i did insert a generated column with an EntityComboBox which i populate and set the selected item. All looks fine.
But, the new selected value is not stored in the entity. What to do ?
Best regards
In a Browse-View i did insert a generated column with an EntityComboBox which i populate and set the selected item. All looks fine.
But, the new selected value is not stored in the entity. What to do ?
Best regards
Hello!
You can use inline editor to edit entity attributes in datagrid.
Here is a quick example how to do it: Inline editor sample
Hi
I am able to edit the way i want.
But finally the values should be saved in the database.
@Autowired
private DataContext dataContext;
@Autowired
private UiComponents uiComponents;
@Autowired
private Metadata metadata;
private EntityComboBox<OrderState> picker = null;
@Subscribe(id = "ordersesDc", target = Target.DATA_CONTAINER)
public void onOrdersesDcItemChange(InstanceContainer.ItemChangeEvent<Orders> event)
{
ArrayList<OrderState> selectedState = new ArrayList<>(picker.getLookupSelectedItems());
System.out.println("selected = " + selectedState.size() + ") " + selectedState.get(0).getState() + " " + selectedState.get(0).getDescription() );
dataContext.commit();
}
@Autowired
protected CollectionContainer<OrderState> orderStatesDc;
@Install(to = "ordersesTable.orderState", subject = "columnGenerator")
private Component ordersesTableOrderStateColumnGenerator(final Orders orders)
{
picker = uiComponents.create(EntityComboBox.class);
picker.setMetaClass(metadata.getClass(OrderState.class));
picker.setOptionsContainer(orderStatesDc);
picker.setValue(orders.getOrderState());
picker.setWidth("100px");
return picker;
}
In onOrdersesDcItemChange i should get the SelectedItem. But it is everytime the last item in the picker list. What am I doing wrong ?