I have a grid column that gets values from a List and display the data in a Combobox.
The problem is when i get the data from Database and display the data on the grid it is displaying the model and not the value.
Combo:
MotivoDAO motivoDAO = new MotivoDAO();
motivo = motivoDAO.findMotivos();
ComboBox<MotivoRecusa> recusaGrid = new ComboBox<>("Recusa", motivo);
recusaGrid.setItemCaptionGenerator(MotivoRecusa::getDescricao);
recusaGrid.setPlaceholder("Nenhum Motivo Selecionado");
recusaGrid.setWidth(350.0f, Unit.PIXELS);
Column:
grid.addColumn(new ValueProvider<ItemOrdemNf, MotivoRecusa>() {
@Override
public MotivoRecusa apply(ItemOrdemNf item) {
for(MotivoRecusa m : motivo) {
if(m.getMotivoId().equals(item.getRecusa())) {
return m;
}
}
return null;
}
}).setEditorComponent(recusaGrid, new Setter<ItemOrdemNf, MotivoRecusa>() {
@Override
public void accept(ItemOrdemNf item, MotivoRecusa ldt) {
if(ldt == null) {
item.setRecusa(null);
} else {
item.setRecusa(ldt.getMotivoId());
}
}
})
.setId("recusa").setCaption("Motivo Recusa").setExpandRatio(4);
The point is this return m;, the corret would be return m.getDescription();. if i change the return to String i start having a lot of conflicts and nothing works, any sugestion?