Sunday, October 30, 2011

Re: How to align header/footer text in cell table

Actually, I just got it working by creating my own HTMLHeader and HTMLCell.  Here it is: 

1. The HTMLHeader class: 
import com.google.gwt.user.cellview.client.Header;

public class HTMLHeader extends Header<String> {
private String html;

public HTMLHeader(String html) {
super(new HTMLCell());
this.html = html;
}

@Override
public String getValue() {
return html;
}
}


2. The HTMLCell class:
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;

public class HTMLCell extends AbstractCell<String> {
public HTMLCell() {
}

@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
if (value != null) {
sb.appendHtmlConstant(value);
}
}
}


3. Add the HTMLHeader aligning it to the right: 
myTable.addColumn(myColumn, new HTMLHeader("<div align=\"right\">Hooray</div>")); 


And you're done!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/DfzFqJflMn8J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment