2

I need add new style for some DataGrid rows, depending on variable.

For example:

table.setRowStyles(new RowStyles<Entry>() {
    @Override
    public String getStyleNames(Entry entry, int rowIndex) {
        return entry.isStyle() ? "newStyle" : null;
    }
});

"newStyle" is global css style.

The problem is style not applied to rows until i add !important to css definition. But with !important i lost all default DataGrid styles and have only "newStyle".

UPDATE: css file

.newStyle {
    color : lightgray;
}
mishadoff
  • 10,719
  • 2
  • 33
  • 55
  • 2
    Please, add your css here! It seems the bad practice to use `!important`. See [What does !important mean in CSS?](http://webdesign.about.com/od/css/f/blcssfaqimportn.htm) Also, see the [gwt-theme-style-overrides-my-css-style](http://stackoverflow.com/questions/2322779/gwt-theme-style-overrides-my-css-style) question. It may be helpful. – MockerTim Jan 17 '12 at 18:26

2 Answers2

1

See this previous question for the working solution. Copied for convenience:

In short extend the DataGrid.Style (the goal is only to have a new type, you don't have to add anything to it) and have your dataGridStyle overridden method return your own subtype rather than DataGrid.Style (and it'll work because of return-type covariance)

Community
  • 1
  • 1
Chris Cashwell
  • 22,308
  • 13
  • 63
  • 94
1

Change the definition of newstyle in your CSS file. Usually it is better to make your CSS selector more specific rather than using !important. Try combining the default DataGrid CSS names with yours. For example: dataGridHeader.newStyle {}

Dusty Campbell
  • 3,146
  • 31
  • 34