0

I am looking to add a label and image to a CellTable column, with following requisites:
- Label should be followed by an image.
- Click on the column (anywhere on label or image), toggles the image.

I am thinking of creating a custom widget containing an HorizontalPanel. Which in itself contains the Label and Image. Before putting substantial time on the same, just want an confirmation whether this approach is proper ?

AM01
  • 302
  • 3
  • 18

1 Answers1

2

No, you cannot put a widget in a CellTable. You will have to make a custom cell (extend AbstractCell) and generate HTML directly.

Take a look at GWT's implementation of different cells to see how they achieve clicking, etc. There are no nice ClickEvents, for example - you have to respond to the browser events directly.

To toggle an image you will have to re-draw the entire table, or use crazy javascript that you don't want to use.

Riley Lark
  • 20,660
  • 15
  • 80
  • 128
  • Thanks. Let me explain further. I have a virtual scrolling grid using two CellTables. HeaderCellTable contains only the headers, while the DataCellTable has the data (more appended as the scrollbar is pulled down). I need the columns in the HeaderCellTable to help in displaying sorting information. If i click on a column of the headercelltable, I want to change the sort arrow (Need help here!). Thereafter i will refresh dataCellTable with new data from server. – AM01 Jun 12 '12 at 17:21
  • 1
    Ah. I have this problem too in my application. We solved it by making the header table out of a Grid, which allows widgets. You could also just redraw the header table instead of both tables, obviously. The `cell` you create will have to choose whether to draw an up arrow or down arrow, depending on the sorted state of the columns. I think CellTable also supports column sorting natively, and may have already solved the up/down arrow problem. – Riley Lark Jun 12 '12 at 18:34
  • Thanks again. I couldn't have used one single CellTable unfortunately (as explained above). I am leaning towards using DataGrid now and rewrite. One other requisite i have is of having some fired and some floating columns. I cycle through the floating ones by using left/right buttons. What would you suggest? As i see that you have used something similar. Thanks again. – AM01 Jun 12 '12 at 19:00