PDA

View Full Version : It is not possible to change cell styles



paucarre
28 Feb 2012, 12:25 AM
There is no way to change the cell styles of a grid. It is only possible to change the text styles, but not the whole cell.
There is a way to change the whole cell style in the 2.x version as explained in:
http://ui-programming.blogspot.com/2010/01/gxt-how-to-set-cell-grid-background.html
(http://ui-programming.blogspot.com/2010/01/gxt-how-to-set-cell-grid-background.html)You should use ColumnData class to modify the styles of the grid. This class exitsts in GXT 3.x but it is not accessible from the renderer. It is to say, the operation "public void render(Cell.Context context, C value, SafeHtmlBuilder sb)" of the class "PropertyDisplayCell<C>" cant access any instance of the class "ColumnData".
Finally, is it not possible to change the styles of the whole cell as you only have access to the inner text. The only way to change the text style is to do something like:


@Override
public void render(com.google.gwt.cell.client.Cell.Context context, T value, SafeHtmlBuilder safeHtmlBuilder) {
safeHtmlBuilder.appendHtmlConstant("<span style='"+customStyle+"'>");
super.render(context, value, safeHtmlBuilder);
safeHtmlBuilder.appendHtmlConstant("</span>");
}


But, as said, it is not possible to change the whole cell style.
In fact there is no usage of the class ColumnData:
http://dev.sencha.com/deploy/gxt-3.0.0-beta3/javadoc/gxt/com/sencha/gxt/widget/core/client/grid/class-use/ColumnData.html

sven
28 Feb 2012, 12:29 AM
Doesnt the GridViewConfig object work for you?

paucarre
28 Feb 2012, 4:16 AM
I have tried to return the styles using many formats following the comments of the interface but it seems not to work.
For example, I tried: return "background-color:green;"; return "background-color:green"; return "{background-color:green;}";return "{background-color:green}";
No one of them worked.

sven
28 Feb 2012, 4:22 AM
You need to return css classnames.

paucarre
28 Feb 2012, 4:52 AM
I assume I have to return a list of class names and GXT will add that class names to the cells/rows. The problem I have is that I have to generate the styles in a dynamic way, so I cant define them in a static CSS file.