I have followed the example code laid out in an earlier posting regarding styling GWT CellTables, replicating the code for the new GWT 2.4 DataGrids. Unfortunately, nothing seemed to work. All I want to do is set the font-size of the cells smaller, so in my local css file (see the second parameter of the @Source annotation in the linked post) I included:
.dataGridCell {
font-size: 6px;
}
Nothing happened. The font size stubbornly refused to change. Then I noticed this in the DataGrid code:
@ImportedWithPrefix("gwt-CellTable")
public interface Style extends CssResource {
I copied DataGrid into my workspace, along with the related three gif files, and commented out the one dependency on a protected method in AbstractCellTable (no empty table widgets -- oh well). I changed the prefix defined in the annotation to gwt-DataGrid -- and pfffft! -- still it didn't work.
So what am I missing here? Is that gwt-CellTable prefix correct in the annotation? Seems fishy to me, though I failed to get it to work with my change.
Turns out the names matter. Duh!
OK, got it working. Turns out it matters to use the same names. Duh!
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.cellview.client.DataGrid;
import com.google.gwt.user.cellview.client.DataGrid.Style;
import com.google.gwt.user.cellview.client.DataGrid.Resources;
public interface MyDataGridResources extends Resources {
public static final MyDataGridResources INSTANCE = GWT.create(MyDataGridResources.class);
@Override
@Source({DataGrid.Style.DEFAULT_CSS, "../resources/styling/mydatagridstyles.css"})
Style dataGridStyle(); // ***********************
}
When I made the name of the style the same as the name of the style interface in DataGrid.java ("dataGridStyle") then it started working.
I sorta kinda get it...but not quite. I will need think more about scoping rules, and also study exactly what happens to the resources parameter passed into the DataGrid constructor.