Search code examples
javagwtgwt2gwt-celltable

GWT Alternative Cell


How to create GWT Cells alternatively at my Columns of Cell Table ?
For instance: I have one column and even rows will show Button Cells and odd rows will show Text Cells. Can it be possible ? If yes , how can I figure it out ? Thanks for any suggestions !

Below image is an example ....

enter image description here


Solution

  • You can build a custom cell, which would render differently based on its context:

    @Override
    public void render(Context context, String value, SafeHtmlBuilder sb) {
        if (context.getIndex() & 1 == 0) {
            // render one way
        } else {
            // render the other way
        }
    }