新的 GWT 2.4 DataGrid - 不是样式 - 注释错误?
我已按照 之前的帖子中列出的示例代码进行操作 关于 GWT CellTables 样式,复制新 GWT 2.4 DataGrids 的代码。不幸的是,似乎没有什么效果。我想要做的就是将单元格的字体大小设置得较小,因此在我的本地 css 文件中(请参阅链接帖子中 @Source 注释的第二个参数)我包括:
.dataGridCell {
font-size: 6px;
}
什么也没发生。字体大小固执地拒绝改变。然后我在 DataGrid 代码中注意到这一点:
@ImportedWithPrefix("gwt-CellTable")
public interface Style extends CssResource {
我将 DataGrid 以及相关的三个 gif 文件复制到我的工作区中,并注释掉了 AbstractCellTable 中受保护方法的一个依赖项(没有空表小部件 - 哦,好吧)。我将注释中定义的前缀更改为 gwt-DataGrid ——然后噗! ——还是没用。
那么我在这里缺少什么?注释中的 gwt-CellTable 前缀正确吗?尽管我没能让它与我的更改一起工作,但对我来说似乎很可疑。
事实证明,名字很重要。呃!
好的,成功了。事实证明,使用相同的名称很重要。呃!
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(); // ***********************
}
当我将样式的名称设置为与 DataGrid.java 中样式接口的名称相同(“dataGridStyle”)时,它就开始工作了。
我有点明白了……但不完全明白。我需要更多地考虑范围规则,并准确研究传递到 DataGrid 构造函数中的资源参数会发生什么情况。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我只是按照您链接的帖子中所述进行操作到,并且它按预期工作。我的
Resources
类如下所示:然后在创建
DataGrid
实例时使用该类:I just did it as described in the post you are linking to, and it works as expected. My
Resources
class looks like that:And then use that class when creating the
DataGrid
instance:当您覆盖由 GWT CSS 文件设置的样式时,您需要在自己的 CSS 定义中添加“!important”。像这样:
When you overwrite a style which is being set by the GWT CSS file, you need to add "!important" in your own CSS definition. Like this:
使用该行时要小心,
这意味着 gwt 同时使用默认的 CSS 和您自己的 CSS。我知道它是这样编码的,但是当你使用 copy &粘贴你可能会像我一样感到困惑为什么两种风格在一起。
be careful when using the line
it means gwt uses both the default and your own css. i know it is coded like that but when you use copy & paste you may get confused like me why do you have both styles together.