GWT-数据网格选择颜色
有没有办法更改gwt datagrid的全局选择颜色? 我在主应用程序css文件中添加了以下css格式:GWT-数据网格选择颜色,gwt,Gwt,有没有办法更改gwt datagrid的全局选择颜色? 我在主应用程序css文件中添加了以下css格式: .dataGridSelectedRow { background: #1EDA17; color: white; height: auto; overflow: auto; } 我还看到了以下链接: 可悲的是,我的改变毫无效果。 我是否错过了任何setStyleName()调用?自定义css将无法工作,因为GWT使用clean.css覆盖它。如果您使用FIREBUG或任
.dataGridSelectedRow {
background: #1EDA17;
color: white;
height: auto;
overflow: auto;
}
我还看到了以下链接:
可悲的是,我的改变毫无效果。
我是否错过了任何setStyleName()调用?自定义css将无法工作,因为GWT使用clean.css覆盖它。如果您使用FIREBUG或任何其他工具,您可能会认出它。解决办法很简单。添加对于未受自定义css影响的每一行都很重要
.dataGridSelectedRow {
background: #1EDA17 !important;
color: white !important;
height: auto !important;
overflow: auto !important;
}
还有另一种为DataGrid中的选定行设置自定义css格式的方法。您需要创建扩展DataGrid.Resources的自定义接口。在这个界面中,您应该使用ovveride方法dataGridStyle()并在@Source注释中输入自定义css文件的路径。 例如:
import com.google.gwt.user.cellview.client.DataGrid;
import com.google.gwt.user.cellview.client.DataGrid.Resources;
public interface CustomDataGridResources extends Resources {
public interface CustomDataGridResources extends Resources {
@Source({DataGrid.Style.DEFAULT_CSS, "resources/CustomDataGridStyles.css"})
CustomStyle dataGridStyle();
interface CustomStyle extends DataGrid.Style {
}
}
如果只想更改选定行的样式,则css文件将仅包含:
.dataGridSelectedRow {
background: #1EDA17;
color: white;
height: auto;
overflow: auto;
}
但我也更喜欢更改howered行的光标:
.dataGridHoveredRow {
cursor: pointer;
cursor: hand;
}
再看看
要将自定义样式应用于DataGrid,可以使用grid的构造函数
public DataGrid(int pageSize, Resources resources, ProvidesKey<T> keyProvider)
谢谢你的提示。带有.gwt按钮{font size:150%!important;}的示例正在运行,但是.dataGridSelectedRow{background:#1EDA17!important;color:white!important;height:auto!important;}没有效果。我还尝试了其他一些datagrid css属性,但也没有效果。看起来datagrid忽略了一切。
DataGrid.Resources customDataGridResources = GWT.create(CustomDataGridResources.class)