no RadioButtonCell in GWT 2.4 Cell?

293 views
Skip to first unread message

tong123123

unread,
Feb 7, 2012, 11:28:26 AM2/7/12
to Google Web Toolkit
I check the GWT 2.4 API
and found there is no RadioButtonCell, so if I need a column with
radio button on each row, how to do it using GWT 2.4? any easy method
or must custom write once?

kretel

unread,
Feb 7, 2012, 11:34:15 AM2/7/12
to google-we...@googlegroups.com
Have a look at showcase samples: 


Regards, 
Kris

Philippe Lhoste

unread,
Feb 7, 2012, 12:15:53 PM2/7/12
to Google-We...@googlegroups.com

Why would you want a radio button per row? To select only one row?

--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --

tong123123

unread,
Feb 8, 2012, 12:31:31 AM2/8/12
to Google Web Toolkit
yes, exactly. I want to show several rows in a cellTable, each row has
a radio button, user select that radio button and press a button,
then the detail of that row will be shown.
any method?

Thomas Broyer

unread,
Feb 8, 2012, 4:08:41 AM2/8/12
to google-we...@googlegroups.com
You can use a CheckboxCell coupled with a SingleSelectionModel, the selection model will take care of keeping only a single checkbox selected.

Or search the archives of this group, someone posted a RadioButtonCell implementation a few months ago.

tong123123

unread,
Feb 21, 2012, 5:21:18 AM2/21/12
to google-we...@googlegroups.com
I don't know how to use a CheckboxCell coupled with a SingleSelectionModel.
CheckboxCell selected = new CheckboxCell();
Column<Log, Boolean> chkColumn = new Column<Log, Boolean>(selected){
   public Boolean getValue(Log log){
        return log.getSelected();
   }
};

table.addColumn(chkColumn, "selected");
final SingleSelectionModel<Log> singleSelectionModel = new SingleSelectionModel<Log>();
table.setSelectionModel(singleSelectionModel);

but when I run the program, I found that if I click on a row, the row get focus first, then I need a second mouse click to cause to checkbox checked, then if I click the checkbox in another row, that row get selected but the checkbox of that row is not checked and I need to click the checkbox once again to selected it.

why will this happen?

tong123123

unread,
Feb 21, 2012, 5:39:55 AM2/21/12
to Google Web Toolkit
I try to add a SelectionChangeHandler to the table as follow:
singleSelectionModel.addSelectionChangeHandler(new
SelectionChangeEvent.Handler(){
public void onSelectionChange(SelectionChangeEvent event){
Log selectedLog =
singleSelectionModel.getSelectedObject();
selectedLog.setSelected(true);
}});
table.setSelectionModel(singleSelectionModel);

but after adding this code, user can select multi checkbox now!!
So how to make a table with a column checkbox and then only allow user
to select one checkbox only?
Reply all
Reply to author
Forward
0 new messages