Browsers apply CSS to tables in a funny way.  TD elements are basically
isolated from the rest of the document, so if you apply a style to the body
element (or even table element), it doesn't carry through to the td elements
in the table.

The workaround is to provide a style for the TD elements, but you have to be
very careful to avoid decendent selectors or your app's performance will
suffer.  You will want to override CellTable.Resources and CellTable.Styles
to provide your own custom styles to the CellTable.  The dev
guide<http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html#CssResource>provides
documentation.  The DynaTableRf sample is a good example of how you
can provide your own CellTable styles that extend the default styles.  Take
a look at 
SummaryWidget.java<http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/widgets/SummaryWidget.java>
.

/* Applies to the body, but not TD */
body {
  font-style: Ariel;
}

/* Applies to the body and all TD.  This is safe. */
body, td {
  font-style: Ariel;
}

/*
 * DO NOT DO THIS.
 * Applies to TD elements in a table styled with myFontStyle.  However, the
browser will
 * match ALL TDs on the page to this rule, then walk up the DOM looking for
a table styled
 * with "myFontStyle".  In the degenerate case, you have hundreds of TD
cells that walk up
 * to the body element before failing.  This could cause noticeable lag in
your application.
 */
table.myFontStyle td {
  font-style: Ariel;
}

/*
 * Applies to TD elements with the style name "myFontStyle".  This is the
best way to apply
 * a table specific style.
 */
td.myFontStyle {
  font-style: Ariel;
}



Thanks,
John LaBanca
jlaba...@google.com


On Tue, Feb 15, 2011 at 6:25 PM, Budric <bud...@gmail.com> wrote:

> Hi,
>
> My custom cell which extends AbstractCell doesn't get the same style
> as the rest of the table.
>
> I add a style to the table using: table.addStyleName("myFontStyle");
> which just changes the font size.  The table renders fine, but the
> cell doesn't. The cell does not have addStyleName() or anything like
> that.
>
> I also tried to surround the result of render() in <div
> class=myFontStyle>.  In that case the rest of the table styles don't
> apply.
>
> Thanks.
>
> --
> 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-web-toolkit@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
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-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to