Definitely use the built-in methods in GWT 2.2, as Thomas linked. However, 
If you cant upgrade for some reason, this snippet served me well:

public class MyCellTable extends CellTable {

   // ... other methods ...

    public void setColumnWidths(String... widths){
        NodeList<Element> colgroups = TableElement.as(getElement())
            .getElementsByTagName("colgroup");
        if(colgroups.getLength() == 1){
            TableColElement cge = TableColElement.as(colgroups.getItem(0));
            NodeList<Element> cols = cge.getElementsByTagName("col");
            for(int i = 0; i < widths.length; i++){
                TableColElement column = null;
                if(cols.getLength() > i){
                    column = TableColElement.as(cols.getItem(i));
                }else{
                    column = 
cge.appendChild(Document.get().createColElement());
                }
                column.setWidth(widths[i]);
            }
        }
    }

}

Usage:

MyCellTable table = new MyCellTable();
table.addColumn(new Column());
table.addColumn(new Column());
table.setColumnWidths("100px", "50%");

I believe I got this from someone else in this group, but I forget who 
(sorry!)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to