How to update CellTable's Header Cell based on action in data table

682 views
Skip to first unread message

Jason

unread,
Apr 29, 2011, 3:31:25 PM4/29/11
to Google Web Toolkit
Hey everyone! I have a question that I cannot seem to find the right
answer to. I'm using a 2 cell tables, one for a fixed header with one
row that scrolls with the other which holds my main data rows.
Basically, I want to implement a tri-state checkbox in one of the
column headers. I was successfully able to create a new
TriStateCheckboxCell that extends AbstractCell and it is wrapped by a
Header<Enum>. Using this class I render either an unchecked input
(checkbox) when no rows in the main table are selected, a checked
input when all the rows in the main table are selected, or an img that
represents an intermediate state of a checkbox when only some of the
rows in the main table are selected. Using a ValueUpdater I can
select all or none of the rows in the main table when the Header's
TriStateCheckboxCell is clicked. All of this works fine. My problem
comes when the user selects a row in the main table and I want to set
the Header's checkbox to the intermediate state. This calls for me to
update or re-render the contents of the Header Cell when the selection
model has been changed. So in my SelectionModel's
SelectionChangeEvent onSelectionChange method I need to update the
cell. This would involve calling it's onBrowserEvent or setValue
method, both of which take the parent Element as a parameter. Only,
Cell does not contain a reference to or extend the Element class. The
problem is that in order to re-render the Cell, I need it's parent
Element. Obtaining this Element is not straightforward to me. I was
able to get it by manually traversing the DOM via the
CellTable.getElement and going down, however this is not ideal. Is
there other methodology that I am not aware of? Am I thinking about
this the wrong way? Thanks!

Thomas Broyer

unread,
Apr 29, 2011, 6:23:32 PM4/29/11
to google-we...@googlegroups.com
You might be looking for the CellTable#redrawHeaders() method. In your SelectionHandler, you would update the internal value of your Header (whatever is returned by its getValue method) and then redrawHeaders() to update the display.
(just an idea, never ever tried)

Jason

unread,
May 2, 2011, 10:30:48 AM5/2/11
to Google Web Toolkit
Darn it! I think I was just staring at my code for too long last
Friday. Thanks Thomas! I was successfully able to update my header
cell's value in the onSelectionChange method of my SelectionHandler
and call redrawHeaders() which successfully re-renders the header
cell. I'm not sure how I missed this workflow the first go around.

On Apr 29, 6:23 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
> You might be looking for the CellTable#redrawHeaders()<http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/googl...()>method. In your SelectionHandler, you would update the internal value of
Reply all
Reply to author
Forward
0 new messages