Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Issue in converting list of buttons from radio group to checkbox and vice versa based on different button selection - 12.1-p20200709 SmartGWT

    Version of Smart GWT is 12.1-p20200709

    Scenario is we have 2 list of button inside 2 layouts
    list 1 -> samsung, sony, mi
    list 2 -> tv, phone, ac

    there are 2 buttons: brand and type

    on click of brand button:
    list 1 will be as radio group (single selection)
    list 2 will be checkbox (multiple selection)

    on click of type button:
    list 1 will be checkbox (multiple selection)
    list 2 will be radio group (single selection)

    below is my code to create and switch buttons:

    create radio button for brand list
    IButton getRadioButton(String id, String title) {
    IButton button = new IButton();
    button.setTitle(title);
    button.setID(id);
    button.setRadioGroup("grp1");
    button.setActionType(SelectionType.RADIO);
    return button;
    }

    create checkbox button for type list
    IButton createCheckboxButton(String id, String title) {
    IButton button = new IButton();
    button.setTitle(title);
    button.setID(id);
    button.setActionType(SelectionType.CHECKBOX);
    return button;
    }

    then on type button click i am removing radio group for brand list and converting to checkbox and adding radio group to type list and converting to radio

    typeButtons.stream().forEach(b -> {
    b.setRadioGroup("grp1");
    b.setActionType(SelectionType.RADIO);
    });

    brandButtons.stream().forEach(b -> {
    b.removeFromRadioGroup();
    b.setActionType(SelectionType.CHECKBOX);
    });


    but i am receiving all button as checkbox as both list of buttons have multiple selection.
    Last edited by sidharth1917; 19 Aug 2020, 03:24.

    #2
    Previously it would have been necessary to call removeFromRadioGroup and explicitly clear the selected state before calling addToRadioGroup(), but we've improved things so that now just calling setRadioGroup() or addToRadioGroup() will work, as your code does, will work. This is available in tomorrow's builds.

    Comment

    Working...
    X