I am trying to display radioButtonGroup component in dataGrid with reference to the documentation of renderer as follows but I get Combox box. The field value is coming from Enum.
@Supply(to = "interviewAssessmentDetailTable.interviewScore", subject = "renderer")
private Renderer<InterviewAssessmentDetail> interviewAssessmentDetailTableInterviewScoreRenderer() {
return new ComponentRenderer<>(
() -> {
RadioButtonGroup radioButtonGroup = uiComponents.create(RadioButtonGroup.class);
radioButtonGroup.setReadOnly(false);
return radioButtonGroup;
},
(radioButtonGroup, customer) -> radioButtonGroup.setValue(customer.getInterviewScore())
);
}
I am getting combobox instead of RadioButtonGroup component.
krivopustov
(Konstantin Krivopustov)
December 15, 2023, 6:25am
2
You need to let the component know what options it has:
@Supply(to = "interviewAssessmentDetailTable.interviewScore", subject = "renderer")
private Renderer<InterviewAssessmentDetail> interviewAssessmentDetailTableInterviewScoreRenderer() {
return new ComponentRenderer<>(
customer -> {
// create Jmix variant of the component:
JmixRadioButtonGroup radioButtonGroup = uiComponents.create(JmixRadioButtonGroup.class);
radioButtonGroup.setReadOnly(false);
radioButtonGroup.setItems(InterviewScore.class); // your enum class
radioButtonGroup.setValue(customer.getInterviewScore());
return radioButtonGroup;
}
);
}
1 Like
The radio button is working fine which is loaded from enum.
I have noticed that the radio button I selected from the table (composition) is not saved. It is saved only when I use a comboBox to exit inline. How can I fix this?
krivopustov
(Konstantin Krivopustov)
January 16, 2024, 7:50am
6
mortoza_khan:
How can I fix this?
Please provide a test project where we could reproduce the issue.
Hi Konstantin
I have created a demo project as requested.
Go to Feedback menu and create new.
In detail screen, click on “Refresh” button to automatically populate data as follows"
Change the radio button from the table and save it. check it back, you will see ‘no change’ saved.
Here is the project.
radiobuttonDatagrid.zip (127.5 KB)
krivopustov
(Konstantin Krivopustov)
January 18, 2024, 8:32am
8
Hi Mortoza,
You should change the component value as follows:
@Supply(to = "feedbackLineDataGrid.rationale", subject = "renderer")
private Renderer<FeedbackLine> feedbackLineDataGridRationaleRenderer() {
return new ComponentRenderer<>(
feedbackLine -> {
// create Jmix variant of the component:
JmixRadioButtonGroup<Rationale> radioButtonGroup = uiComponents.create(JmixRadioButtonGroup.class);
radioButtonGroup.setReadOnly(false);
radioButtonGroup.setItems(Rationale.class); // your enum class
radioButtonGroup.setValue(feedbackLine.getRationale());
// save changed value in the entity
radioButtonGroup.addValueChangeListener(valueChangeEvent -> {
feedbackLine.setRationale(valueChangeEvent.getValue());
});
return radioButtonGroup;
}
);
}
2 Likes
Thank you so much, Konstantin. It worked perfectly.