mishadoff
mishadoff

Reputation: 10789

How to add specific style to GWT DataGrid

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;
}

Upvotes: 2

Views: 5088

Answers (2)

Dusty Campbell
Dusty Campbell

Reputation: 3156

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 {}

Upvotes: 1

Chris Cashwell
Chris Cashwell

Reputation: 22899

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)

Upvotes: 1

Related Questions