2

I am implementing multiple themes in our GWT applications.

The problem is when a DataGrid is constructed, I can't find a way to change the style resource that has been passed to it. Does anybody know how to solve the problem. Or on every theme change, do we have to reconstruct the grid?

Any other new idea to solve the problem (having multiple themes on these widgets) is appreciated.

Thanks.

Blessed Geek
  • 21,058
  • 23
  • 106
  • 176
Hamzeh
  • 541
  • 7
  • 15

2 Answers2

0

You could use uibinder.

At this page

https://developers.google.com/web-toolkit/doc/latest/DevGuideUiBinder#Programmatic_access,

search for the section

Programmatic access to inline Styles

However, you need to be familiar with uibinder.

Blessed Geek
  • 21,058
  • 23
  • 106
  • 176
  • Thanks, but in fact in GWT DataGrid normally we have some obfuscated CSS classes which can't be modified simply by adding/removing styles. The styles of thsese widgets are passed to their constructors when they are going to be constructed. – Hamzeh Aug 14 '12 at 05:09
0

I was able to do this using -

cellTable.setRowStyles(new RowStyles>() {

        @Override
        public String getStyleNames(Map<String, String> row, int rowIndex) {
            if (rowIndex % 2 == 0) {
                return "cellTableEvenRow";
            } else {
                return "cellTableOddRow";
            }
        }
    });

Since, I had to provide the user 3 color themes, I used 3 style sheets for each color and specified the below style with different colors in each style sheet.

.cellTableEvenRow {
    background: #fffff !important;
}
.cellTableOddRow {
    background: #E9FDE4 !important;
}

Hope it helps!