I'm working on a GWT app, and so far I'm loving the Java developer friendly UI framework!
So far I've been able to do pretty much anything with the widgets, but this one has me stumped. I have a cell table, that I use as a user input source. Its just a way for users to enter key-value pairs to call my service. User can dynamically add rows and delete rows.
Now the tricky part is I want to force the user to enter value for some keys. There are only certain 4-5 acceptable values for these keys so for those rows I would like to replace the editableTextCell with a selectionCell. Not sure how I can mix cell types within a table, given that the column cell type declaration is done while adding the column to the table.
Any input is appreciated!
Thanks
You'll have to create a custom Cell that sometimes renders a <select>
and sometimes renders an <input>
. If you look at the code of EditableTextCell and SelectionCell you can get ideas about how to accomplish that. It may be pretty simple - you could compose one of each, and in your render
function just pass the data to the appropriate cell.
Something like...
public class ChoosyCell extends AbstractCell<YourData> {
SelectionCell selectCell = new SelectionCell<YourData>();
EditableTextCell textCell = new EditableTextCell<YourData>();
public void render(Context context, YourData data, SafeHtmlBuilder sb) {
if (data.isTheLimitedType()) {
selectCell.render(context, data, sb);
} else {
textCell.render(context,data, sb);
}
}
}
(untested code)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With