Hi, I want to create custom renderer with two radio buttons Yes and No. I tried following snippet but no luck. I want to show a div under the radio control based on the selected value of the radio button. When user clicks on div I want to handle the click event.
Any help would be appreciated.
import {
JsonSchema,
ControlProps,
RankedTester,
rankWith,
OwnPropsOfEnum,
isEnumControl,
optionIs,
and,
} from '@jsonforms/core';
import { Unwrapped } from '@jsonforms/material-renderers';
import { Grid } from '@mui/material';
const { MaterialRadioGroupControl } = Unwrapped;
type JsonSchemaWithCustomProp = JsonSchema & { isCustom: boolean };
export const radioWithCustomControl = (
props: ControlProps & OwnPropsOfEnum
) => {
const schema = props.schema as JsonSchemaWithCustomProp;
return (
<Grid container>
<Grid item xs={12}>
<MaterialRadioGroupControl {...props} />
</Grid>
</Grid>
);
};
export const radioWithCustomControlTester: RankedTester = rankWith(
21,
and(isEnumControl, optionIs('format', 'radio'))
);
export default radioWithCustomControl;
I am getting below error .
TypeError: Cannot read properties of undefined (reading ‘length’)
MaterialRadioGroup
/src/controls/MaterialRadioGroup.tsx:60
28 stack frames were collapsed.
My schema json
{
"type": "object",
"properties": {
"do_you_own_house": {
"type": "string",
"isCustom": false,
"enum": [
"Yes",
"No"
],
"options": [
{
"label": "some",
"value": "somevalue"
},
{
"label": "nothing",
"value": "nonthingval"
}
]
}
}
}
My uischema json
{
"type": "VerticalLayout",
"elements": [
{
"type": "Control",
"label": "Do you own a house, condo, apartment or other residence",
"scope": "#/properties/do_you_own_house",
"options": {
"format": "radio"
}
}
]
}