How to build text trimming cell for GWT DataGrid

270 views
Skip to first unread message

benb

unread,
Apr 29, 2012, 8:45:59 AM4/29/12
to Google Web Toolkit
Hi,

I'm looking for examples for building a text-trimming cell for GWT
DataGrid.
I want the cell to have fixed width and height, and if text is longer
- ellipsis (...) will appear.
The complete text will appear on editing / on tool tip.

In my current DataGrid, the text is automatically wrapped and the row
height grows. I want to avoid that and to keep fixed row height.

Can someone help?

Thanks,
Ben

Jens

unread,
Apr 29, 2012, 9:00:43 AM4/29/12
to google-we...@googlegroups.com
Apply CSS to your cell:

white-space: nowrap;
overflow:hidden;
text-overflow: ellipsis;

-- J.

Robert W

unread,
Apr 29, 2012, 11:02:09 PM4/29/12
to google-we...@googlegroups.com
If you extend AbstractCell<?> there is access to your model and cell state (view,edit). There you can count chars, traverse dom that suit your needs

Andrei

unread,
May 1, 2012, 3:50:06 AM5/1/12
to Google Web Toolkit
@Jens,

Just to expand on Jen's answer. For this solution to work, you need to
apply it to a div inside a cell:

.myDataGrid td div {

benb

unread,
May 2, 2012, 2:50:48 AM5/2/12
to Google Web Toolkit
Works good, thanks!
Reply all
Reply to author
Forward
0 new messages