Reputation: 8548
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 ....
Upvotes: 0
Views: 98
Reputation: 8548
Thanks sir @AndreiVolgin. Now I got it. Here is my code as sir Andrei Volgin's answer.
ButtonCell buttonCellEdit = new ButtonCell() {
@Override
public void render(final Context context, final SafeHtml data, final SafeHtmlBuilder sb) {
if (i++ % 2 == 0) {
sb.appendHtmlConstant("It is row " + i);
}
else {
sb.appendHtmlConstant("<button type=\"button\" class=\"gwt-Button btn btnBlue\" tabindex=\"-1\">");
if (data != null) {
sb.append(data);
}
sb.appendHtmlConstant("</button>");
}
}
};
Upvotes: 0
Reputation: 41089
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
}
}
Upvotes: 2