Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 2 weeks ago
How to get an item from itemId in a Table's style generator?
In a Table, I want to set a cell's style based on another cell's contents.
So I have a cell style generator working. The problem is the "getStyle" method is passed only an itemId and a propertyId. I need access to another property on the same item.
--> How do I get to an Item instance from only the itemId?
So in this example, I want the FirstName cell to have color if that person is a boss ("IsBoss" property).
// style generator
// The returned style name will be concatenated to prefix "v-table-cell-content-".
table.setCellStyleGenerator(new Table.CellStyleGenerator() {
public String getStyle(Object itemId, Object propertyId) {
if (propertyId == null) {
// no propertyId, styling row
return null;
} else if ("FirstName".equals(propertyId)) {
// How do I get the item?
// I need a sibling property on the same item.
if ( item.getItemProperty( "IsBoss" ).getValue() ) == true ) {
return "is_boss";
} else {
return null;
}
} else {
// no style
return null;
}
}
});
Last updated on Feb, 9th 2012
You cannot reply to this thread.