James203
(James Sweeting)
May 25, 2016, 10:17am
1
I am trying to display a tooltip in a grid cell vaadin 7.6 and it doesn’t work here is my code - can anyone help?
grid.setCellDescriptionGenerator(new Grid.CellDescriptionGenerator() {
@Override
public String getDescription(Grid.CellReference cellReference) {
String tooltip = "";
if (cellReference.getPropertyId().toString().equalsIgnoreCase(CREATED_DATE)) {
String tt = (String) cellReference.getItem().getItemProperty("createdDateToolTip").getValue();
tooltip = tt;
} return tooltip;
}
});
mcollovati
(Marco Collovati)
May 25, 2016, 10:56am
2
Can you please elaborate a little more?
Is the Grid.CellDescriptionGenerator() not invoked at all or is it invoked and processed correctly but the tooltip is not shown on the browser?
James203
(James Sweeting)
May 25, 2016, 11:26am
3
Sorry, I don’t know - how do I find out?
the tooltip isn’t shown anyway
mcollovati
(Marco Collovati)
May 25, 2016, 11:32am
4
The best way is to attach your IDE debugger and place a breakpoint inside the getDescription method.
If you prefer an old style dirty way, place some System.out.println(“…”) inside the method and then check the console output
mcollovati
(Marco Collovati)
May 25, 2016, 11:51am
5
Can you please post some more code? How do you setup the grid and the container?
James203
(James Sweeting)
May 25, 2016, 12:15pm
6
I am trying again to output
James203
(James Sweeting)
May 25, 2016, 12:36pm
7
It is still null
more info:
IndexedContainer container;
Grid grid = new Grid() {
public Component getSearchResultComponent(ViewChangeListener.ViewChangeEvent event) {
container = new IndexedContainer();
container.addContainerProperty(“addOrRemove”, String.class, “”);
container.addContainerProperty(“export”, String.class, “”);
container.addContainerProperty(“createdDate”, Date.class, null);
container.addContainerProperty(“lastUpdatedDate”, Date.class, null);
for (TRVo vo : tRVOs) {
Item newItem = container.getItem(container.addItem());
newItem.getItemProperty(“createdDate”).setValue(vo.getCreatedDate()); newItem.getItemProperty(“lastUpdatedDate”).setValue(vo.getLastUpdatedDate());
grid.setSizeFull();
GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(container);
grid.setContainerDataSource(gpc);
mcollovati
(Marco Collovati)
May 25, 2016, 12:40pm
8
It seems your container has not “createdDateToolTip” property
James203
(James Sweeting)
May 25, 2016, 12:42pm
9
how do I make it do that?
mcollovati
(Marco Collovati)
May 25, 2016, 12:46pm
10
Same way you have done for createdDate or lastUpdatedDate properties.
What do you want to set as tooltip for CREATED_DATE cell? a property of your TRVo bean named createdDateToolTip or must it be a text you generate based on other properties?
James203
(James Sweeting)
May 25, 2016, 1:14pm
11
ok
I should try just setting it to a string first
James203
(James Sweeting)
May 25, 2016, 1:52pm
12
I got a string displaying as a tool tip! Thanks
so there is some problem with the getItemProperty - that can wait!
Can you help me with displaying an image in a grid please?
mcollovati
(Marco Collovati)
May 25, 2016, 1:57pm
13
Take a look at the
documentation
for the Grid component; in the section Column Renderers you will find what you need.
James203
(James Sweeting)
May 25, 2016, 2:25pm
14
I’m getting there - now I am looking for combining image and text in a cell!