how do i add a tooltip to a column header in a celltable ?

1,785 views
Skip to first unread message

Celinio

unread,
May 30, 2011, 2:45:32 PM5/30/11
to google-we...@googlegroups.com
hello,
i just have a simple question :
how do i add a tooltip to a column header in a celltable ?

Thanks for helping.

Juan Pablo Gardella

unread,
May 30, 2011, 8:31:48 PM5/30/11
to google-we...@googlegroups.com
You must do a event handler (overwrite onBrowserEvent2), CellTable in gwt 2.3.0 doesn't support events. See this example:

@Override
protected void onBrowserEvent2(Event event) {
super.onBrowserEvent2(event);

String eventType = event.getType();
boolean isMouseover = "mouseover".equals(eventType);
boolean isMouseout = "mouseout".equals(eventType);

// Get the event target.
EventTarget eventTarget = event.getEventTarget();
if (!Element.is(eventTarget)) {
return;
}
final Element target = event.getEventTarget().cast();


You can overwrite this method and can open a tooltip.



2011/5/30 Celinio <cel...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Celinio

unread,
May 30, 2011, 11:28:31 PM5/30/11
to google-we...@googlegroups.com
thanks for your answer.
I had already explored that onBrowserEvent(...) possibility.

Where do i add that OnBrowserEvent(...) method to exactly ?

Juan Pablo Gardella

unread,
May 31, 2011, 7:23:16 AM5/31/11
to google-we...@googlegroups.com
For example in your column.

2011/5/31 Celinio <cel...@gmail.com>

Celinio

unread,
May 31, 2011, 7:49:07 AM5/31/11
to google-we...@googlegroups.com
Do you suggest something like this ? It's not firing any event when I move the mouse over ....

Column<myDTO, String> utilisateurVerrouColumn = new Column<myDTO, String>(           
new ClickableTextCell(blablaRender)) {
           
public String getValue(myDTO d) {               
    return "something";
}
                   
protected void onBrowserEvent(Event event) {
    //super.onBrowserEvent(event);


    String eventType = event.getType();
    boolean isMouseover = "mouseover".equals(eventType);
    boolean isMouseout = "mouseout".equals(eventType);

    // Get the event target.
    EventTarget eventTarget = event.getEventTarget();
    if (!Element.is(eventTarget)) {
    return;
    }
   
    switch(DOM.eventGetType(event)) {
        case Event.ONMOUSEOVER:
            Window.alert("Mouseover");
            break;                       
            case Event.ONMOUSEOUT:
            Window.alert("Mouseout");
            break;
        default:
             break;
    }
}

};       

Celinio

unread,
May 31, 2011, 7:59:36 AM5/31/11
to google-we...@googlegroups.com
hmm looks like i needed to use the new signature of the method :

public void onBrowserEvent(Cell.Context context,
                               Element elem,
                               DemandeBean object,
                               NativeEvent event) { ...}

However the method is called only if i click in the column.
It is not called if i just move over the mouse.
That's one thing.
Another thing is that I want the tool tip only when the user moves the mouse over the column header, not the entire column.
Any idea ?
Thanks

emir

unread,
Jun 11, 2011, 4:40:52 AM6/11/11
to Google Web Toolkit
If a plain tooltip suffices, you can create the column with a SafeHtml
which specifies the tooltip
text using the title property.

e.g.

CellTable ct;
ct.addColumn(col, SafeHtmlUtils.fromSafeConstant("<span title='!!!tool
tip text goes here!!!'>---header text---</span>"));

vaibhav gwt

unread,
Nov 8, 2011, 2:08:02 AM11/8/11
to emir, google-we...@googlegroups.com
Hi,
Following e.g works only for Name of column header i.e. when we move
mouse on name of column header then only tool tip appear.

CellTable ct;
ct.addColumn(col, SafeHtmlUtils.fromSafeConstant("<span title='!!!tool
tip text goes here!!!'>---header text---</span>"));

We want too tip on entire column header not on name of column header.

Any solution ?

Reply all
Reply to author
Forward
0 new messages