CellList grid

13 views
Skip to first unread message

noach

unread,
Nov 6, 2011, 8:33:12 AM11/6/11
to Google Web Toolkit
Is there a way to display elements of a cell list in a grid format?
For example, if there were 8 items, the cells might be arranged as
follows:

Item1 Item4 Item7
Item2 Item5 Item8
Item3 Item6

Danny Kirchmeier

unread,
Nov 7, 2011, 9:10:01 AM11/7/11
to google-we...@googlegroups.com
It's a bit of a hack, but since the cell list is just a list of Divs, you can use the CSS3 columns (but watch out, IE9 doesn't support this, and only the most recent version of opera does)

public void setColumns(int columns) {
    if(columns < 1) columns = 1;

    Style style = cellList.getElement().getStyle();
    String cols = String.valueOf(columns);
    /* You could used deferred binding here if you weren't lazy */
    style.setProperty("MozColumnCount", cols);
    style.setProperty("WebkitColumnCount", cols);
    style.setProperty("columnCount", cols);
}

public void setColumnPadding(int width) {
    if(width < 0) width = 0;

    Style style = cellList.getElement().getStyle();
    style.setProperty("MozColumnGap", width, Style.Unit.PX);
    style.setProperty("WebkitColumnGap", width, Style.Unit.PX);
    style.setProperty("columnGap", width, Style.Unit.PX);
}

Reply all
Reply to author
Forward
0 new messages