如何将不同的 css 样式应用于同一页面中的 gwt datagrid 小部件?
How to apply different css style to gwt datagrid widget in the same page?
我使用这个解决方案
How to override GWT obfuscated style for DataGrid header
覆盖 gwt 数据网格小部件的样式,它工作正常,太棒了!
但是现在,我需要在同一页面中使用 2 种不同的 css 样式设置 2 个数据网格的样式。
我该怎么做?
来自您链接到的Q/A:
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.
Then of course, GWT.create()
your DataGrid.Resources
sub-interface and pass it as an argument to the DataGrid
constructor.
See also https://code.google.com/p/google-web-toolkit/issues/detail?id=6144
如果您使用外部 CSS 而不是 CellTableResources,就很容易了。然后你可以简单地为每个 table 分配一个 class 并在你的 CSS 文件中定义规则:
.table1 th {
font-weight:400;
}
.table2 th {
font-weight:700;
}
如果您使用自定义资源,您仍然可以这样做,但您需要将 !important
添加到您的 CSS 规则中。
.table1 th {
font-weight:400 !important;
}
我使用这个解决方案 How to override GWT obfuscated style for DataGrid header 覆盖 gwt 数据网格小部件的样式,它工作正常,太棒了!
但是现在,我需要在同一页面中使用 2 种不同的 css 样式设置 2 个数据网格的样式。
我该怎么做?
来自您链接到的Q/A:
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 yourdataGridStyle
override: because the obfuscated class name is based on both the interface fully-qualified name and the method name, yourDataGrid.Style
sub-interface will generate different obfuscated class names than the originalDataGrid.Style
interface.Then of course,
GWT.create()
yourDataGrid.Resources
sub-interface and pass it as an argument to theDataGrid
constructor.See also https://code.google.com/p/google-web-toolkit/issues/detail?id=6144
如果您使用外部 CSS 而不是 CellTableResources,就很容易了。然后你可以简单地为每个 table 分配一个 class 并在你的 CSS 文件中定义规则:
.table1 th {
font-weight:400;
}
.table2 th {
font-weight:700;
}
如果您使用自定义资源,您仍然可以这样做,但您需要将 !important
添加到您的 CSS 规则中。
.table1 th {
font-weight:400 !important;
}