Discussion:
Radio Button in Cell Table or Data grid.
BM
2018-06-28 16:07:25 UTC
Permalink
Basically to implement custom RadioGroupCell for Cell Table. This is not
having a group of Radio buttons within a single cell.

So what I want is a cell table which has a cell Column called "Active" and
defined with one Radio button in that cell. Unlike checkboxes or custom
cell of group of radio buttons within one cell, my requirement is the Radio
buttons in all rows are part of one Group so one can select only one at a
time.

So here is what cell table would look like

Role Active
------ --------
Admin Radio Button (YES)
Role A Radio Button (NO)
Role B Radio Button (NO)

One can toggle to select only one Radio between roles.

I can write a custom cell which has one radio button. But I don't know how
each radio buttons becomes part of the single group across the rows.

Any help or pointers would be much appreciated.
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
Thomas Broyer
2018-06-28 16:20:36 UTC
Permalink
Fwiw, if this is about selecting a value, have a look at the
SingleSelectionModel and how to apply it to a CheckboxCell. If you want the
additional type="radio" on the <input> (for accessibility, mainly), then
create your own custom cell based on CheckboxCell.
If this is *not* about selection, then I'm afraid it'll be a bit harder, as
you won't have an event/callback/whatever on the "previously selected
radio" when you select another one.
Post by BM
Basically to implement custom RadioGroupCell for Cell Table. This is not
having a group of Radio buttons within a single cell.
So what I want is a cell table which has a cell Column called "Active" and
defined with one Radio button in that cell. Unlike checkboxes or custom
cell of group of radio buttons within one cell, my requirement is the Radio
buttons in all rows are part of one Group so one can select only one at a
time.
So here is what cell table would look like
Role Active
------ --------
Admin Radio Button (YES)
Role A Radio Button (NO)
Role B Radio Button (NO)
One can toggle to select only one Radio between roles.
I can write a custom cell which has one radio button. But I don't know how
each radio buttons becomes part of the single group across the rows.
Any help or pointers would be much appreciated.
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
BM
2018-06-28 16:53:56 UTC
Permalink
Cheers Thomas. You are right on where my struggle is. Hmm.

Ok so where can I find the SingleSelectionModel and how to apply it to a
CheckboxCell example? As long as I can show a widget (either checkbox or
radio) which toggles across each row to put ON or OFF value within the DTO
field I am okay to show checkbox.
Post by Thomas Broyer
Fwiw, if this is about selecting a value, have a look at the
SingleSelectionModel and how to apply it to a CheckboxCell. If you want the
additional type="radio" on the <input> (for accessibility, mainly), then
create your own custom cell based on CheckboxCell.
If this is *not* about selection, then I'm afraid it'll be a bit harder,
as you won't have an event/callback/whatever on the "previously selected
radio" when you select another one.
Post by BM
Basically to implement custom RadioGroupCell for Cell Table. This is not
having a group of Radio buttons within a single cell.
So what I want is a cell table which has a cell Column called "Active"
and defined with one Radio button in that cell. Unlike checkboxes or custom
cell of group of radio buttons within one cell, my requirement is the Radio
buttons in all rows are part of one Group so one can select only one at a
time.
So here is what cell table would look like
Role Active
------ --------
Admin Radio Button (YES)
Role A Radio Button (NO)
Role B Radio Button (NO)
One can toggle to select only one Radio between roles.
I can write a custom cell which has one radio button. But I don't know
how each radio buttons becomes part of the single group across the rows.
Any help or pointers would be much appreciated.
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
BM
2018-06-28 17:03:17 UTC
Permalink
I think I got it. Will this be correct?

private final SingleSelectionModel<DTO> roleStatusSelectionModel = new
SingleSelectionModel<>(KEY_PROVIDER);
roleCellTable.setSelectionModel(roleStatusSelectionModel);

private final CheckboxCell rowSelectionColumnCell = new CheckboxCell(true,
false);

final Column<DTO, Boolean> rowSelectionColumn = new Column<DTO,
Boolean>(rowSelectionColumnCell) {
@Override
public Boolean getValue(final DTO dto) {
return roleStatusSelectionModel.isSelected(dto);
}
}


final Set<DTO> selectedSet = roleStatusSelectionModel.getSelectedSet();

for (final DTO selected : selectedSet) {
selected.setActive(true);
}


Secondly, If I have to do this custom radio based on CheckboxCell, what's
the best way?
Post by Thomas Broyer
Fwiw, if this is about selecting a value, have a look at the
SingleSelectionModel and how to apply it to a CheckboxCell. If you want the
additional type="radio" on the <input> (for accessibility, mainly), then
create your own custom cell based on CheckboxCell.
If this is *not* about selection, then I'm afraid it'll be a bit harder,
as you won't have an event/callback/whatever on the "previously selected
radio" when you select another one.
Post by BM
Basically to implement custom RadioGroupCell for Cell Table. This is not
having a group of Radio buttons within a single cell.
So what I want is a cell table which has a cell Column called "Active"
and defined with one Radio button in that cell. Unlike checkboxes or custom
cell of group of radio buttons within one cell, my requirement is the Radio
buttons in all rows are part of one Group so one can select only one at a
time.
So here is what cell table would look like
Role Active
------ --------
Admin Radio Button (YES)
Role A Radio Button (NO)
Role B Radio Button (NO)
One can toggle to select only one Radio between roles.
I can write a custom cell which has one radio button. But I don't know
how each radio buttons becomes part of the single group across the rows.
Any help or pointers would be much appreciated.
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+***@googlegroups.com.
To post to this group, send email to google-web-***@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...