since there are no more Items, propertiesIds, containers. How to we populate with generic data a grid?
I have a structure like this:
{Id (Integer), Name (String), DNI (Number), Avg salary (BigDecimal), LastVisit (Date)}
This and many other are made from queries (JPA mostly)
How do I put a simple List<Object> data into a grid?
I used to addItem(), then to that Item, setted every Property value from an array[position]
… but now I can’t figure it out
One quick and dirty option, if you don’t want to create a specific row class: use a Map object for row items.
Quick pseudocode example:
[code]
Grid<Map<String, Object> grid = new Grid<>()
List keys = [“id”, “name”, “dni”, “avgsalary”, “lastvisit”]
List<Map<String, Object>> rows = getRows() // return a list of Maps with keys like in the above list
for (String key : keys) {
grid.addColumn(key, rowMap → "hello " + rowMap.get(key) )
// here rowmap is one item from the ´rows` list above
// instead of printing "hello [value]
" you might want to convert each entry to String
}
grid.addItems(rows)
[/code]-Olli