3

I have a cell table that has several columns whose data may occasionally be wider than their column's width.

I have my css text-overflow set to ellipsis so it is obvious to the user that there is more to the cell's value when it exceeds the column's width.

With a "normal" widget, I would just use setTitle() to automatically display the full contents on mouse over, but the TextCell (and all other cell widgets) do not extend UiObject, so they do not have this method available.

A TextCell is implemented by a div within a td tag. Being able to set the title on either elements would give me the behavior I am looking for, but I cannot seem to find a way to get a handle on either of the elements.

What is the best way to get the HTML title behavior to work in a cell table widget?

Thanks,

Doug

Doug
  • 191
  • 2
  • 8

2 Answers2

3

you can write your own cell implementation and set the title in the html template yourself.

Take a look at a cell implementation. Basically they provide the html string for rendering.

Daniel Kurka
  • 7,973
  • 2
  • 24
  • 43
  • I created a widget that extends the TextCell and overrides the render method to add a wrapping div tag whose title I could set. Not sure this is the most elegant solution... – Doug May 16 '11 at 18:02
  • 'code' public class TitledTextCell extends TextCell { public TitledTextCell() { super(); } @Override public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) { if (value != null) { // create yet another div so that we may set it's title sb.appendHtmlConstant("
    "); sb.append(value); sb.appendHtmlConstant("
    "); } } }
    – Doug May 16 '11 at 18:07
  • its not the most elegant, but its okay. You could take a look inside TextCell and change the template to include your title directly (you would save one div) – Daniel Kurka May 16 '11 at 18:56
  • Thanks, this sounds like a great idea. Where in the namespace do I look for the template? – Doug May 17 '11 at 13:19
  • I need the same, just: bla - Surprisingly there is no such method in com.google.gwt.cell.client.Cell(AbstractCell) API, I don't understand why? ( – yetanothercoder Sep 14 '11 at 05:23
0

Some of these kinds of issues have been "fixed" in GWT 2.3. But if you are stuck with using GWT 2.2, then writing your own cell implementation is the way to go.

Basanth Roy
  • 6,272
  • 5
  • 25
  • 25