Tuesday, May 30, 2017

Re: GWT DataGrid background colour for rows

DataGrid being a "cell widget", it will be "re-rendered" regularly, losing all modifications you manually did to the DOM tree.
You can "persist" your changes using setRowStyles for classnames applied to a TableRowElement, or custom column with overridden getCellStyleNames for classnames applied to a TableCellElement, or a custom CellTableBuilder for more complex custom rendering; or you can use a RedrawEvent.Handler to reapply your changes every time the grid is re-rendered.

On Tuesday, May 30, 2017 at 3:50:01 PM UTC+2, Santanu Banerjee wrote:
I am trying to apply background colour to some rows dynamically based on some program logic, but I can see that the colour is disspearing on any further row selection.
I used two approaches to change the colour.
1) baseGrid.getRowElement(i).getCells().getItem(0).addClassName(<css style>);

Use a setRowStyles(), with a RowStyles implementation that returns <css style>
2)TableCellElement cell = grid.getRowElement(i).getCells().getItem(colIndex); cell.getStyle().setProperty("background", "#DDDDDD");

Could you please suggest any alternative ways I can do it. so that the background colour of the rows do not change on any further row selection?


You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment