问题描述
我想弄清楚如何覆盖 DataGrid.css!GWT 核心.GWT 样式名称使用 adler32 进行了混淆,因此我不能在我的 css 中简单地使用 .dataGridHeader.就我而言,我希望对 white-space:normal 进行简单的更改.
I'm trying to figure out how to override the dataGridHeader style defined in DataGrid.css! GWT core. The GWT style name is obfuscated with adler32 so I can't simply use .dataGridHeader in my css. In my case I wish a simple change of white-space:normal.
我在这里看到过可能关于注入 css 的文章,但它们似乎都是类级别的,而不是像 DataGrid 这样的组件中使用的子样式.
I've seen may articles here about injecting css but they all appear to be class level rather than a sub style used within a component like DataGrid.
如何覆盖像 DataGrid 这样的组件中使用的标题样式?
How do I override a header style used within a component like DataGrid?
推荐答案
就像任何 ClientBundle
和 CssResource
一样:创建一个扩展 Datagrid.Resources 的接口
并使用 @Source
批注覆盖 dataGridStyle
方法,该批注指向您自己的 CSS 文件(或可能同时指向原始文件和您自己的文件,因此它们将结合在一起).
Just like with any ClientBundle
and CssResource
: create an interface that extends Datagrid.Resources
and overrides the dataGridStyle
method with a @Source
annotation pointing to your own CSS file (or possibly to both the original file and your own file, so they'll be combined together).
这样做将覆盖所有 DataGrid
在您的应用程序中的样式(它实际上取决于哪个 CssResource
实例获取 ensureInjected()
第一个:来自原始 DataGrid.Resources
或来自您子接口的那个):因为您使用相同的返回类型(DataGrid.Style
),混淆后的类名将相同.
Doing it that way will override the style for all DataGrid
s in your app though (it actually depends on which CssResource
instance gets ensureInjected()
first: the one from the original DataGrid.Resources
or the one from your sub-interface): because you use the same return type (DataGrid.Style
), the obfuscated class names will be the same.
如果您想根据具体情况更改样式,则另外声明一个扩展 DataGrid.Style
的接口,并将其用作 的返回类型dataGridStyle
覆盖:因为混淆类名是基于接口完全限定名和方法名,你的 DataGrid.Style
子接口将生成与原始类不同的混淆类名DataGrid.Style
接口.
If you want to change the style on a case-by-case basis then, in addition, declare an interface that extends DataGrid.Style
and use that as the return type to your dataGridStyle
override: because the obfuscated class name is based on both the interface fully-qualified name and the method name, your DataGrid.Style
sub-interface will generate different obfuscated class names than the original DataGrid.Style
interface.
当然,GWT.create()
你的 DataGrid.Resources
子接口并将其作为参数传递给 DataGrid
构造函数.
Then of course, GWT.create()
your DataGrid.Resources
sub-interface and pass it as an argument to the DataGrid
constructor.
另见 http://code.google.com/p/google-web-toolkit/issues/detail?id=6144
这篇关于如何覆盖 DataGrid 标头的 GWT 混淆样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!