Readonly options - Jsonforms version compatibility with material ui v4

Hi Team,

“options”: {
“readonly”: true
},

This is not working with version 2.5.1. Please find the following details.

@jsonforms/core”: “^2.5.1”,
@jsonforms/material-renderers”: “^2.5.1”,
@jsonforms/react”: “^2.5.1”,
@material-ui/core”: “^4.9.14”,
@material-ui/icons”: “^4.9.1”,
@material-ui/lab”: “^4.0.0-alpha.53”,

These are all the dependencies version.

Which compatible jsonforms version supports “readonly” along with mentioned material-ui versions?

Below are the schemas.

export const testUiSchema = {
type: ‘VerticalLayout’,
elements: [
{
type: ‘Group’,
elements: [
{
type: ‘Control’,
scope: ‘#/properties/field_1’,
options: {
readonly: true,
},
},
],
},
],
};

export const testSchema = {
title: ‘test entity 001’,
type: ‘object’,
properties: {
field_1: {
title: ‘Field 1’,
type: ‘string’,
},
},
required: ,
};

Thanks,
Suseen

Hi @Suseendhiran,

readonly on single controls is supported since 3.0.0-alpha.0. We switched from Material Ui v4 to v5 with v3.0.0-alpha.3. So it seems that 3.0.0-alpha.0, 3.0.0-alpha.1 and 3.0.0-alpha.2 should work for you.

Thanks for your response @sdirix , I did update all the packages to the latest version. readonly options is working now.

But still I’m facing issue with Group Custom layout readonly options.

I have created custom layout for “Group” type, When I add the option readonly:true, it is not becoming effective in this custom layout, means fields inside this group custom layout not becoming disabled, even though I have added <MaterialLayoutRenderer {…layoutProps} />.

Below is my custom layout renderer code. I have added this in jsonforms renderer’s list, I could collapse the Group section, but readonly options is not working,

With default Group renderer, readonly options is working fine.

import React from ‘react’;
import { rankWith, RendererProps, uiTypeIs } from ‘@jsonforms/core’;
import {
MaterialLayoutRenderer,
MaterialLayoutRendererProps,
} from ‘@jsonforms/material-renderers’;
import { withJsonFormsLayoutProps } from ‘@jsonforms/react’;
import { ExpandMore } from ‘@mui/icons-material’;
import {
Accordion,
AccordionDetails,
AccordionSummary,
Typography,
} from ‘@mui/material’;

interface MyGroupRendererProps extends RendererProps {
uischema: any;
// Replace ‘any’ with the appropriate type for your uischema
}

const MyGroupRenderer: React.FC = (props) => {
const { path, visible, renderers, schema, uischema } = props;
const layoutProps: MaterialLayoutRendererProps = {
elements: uischema.elements,
schema: schema,
path: path,
direction: ‘column’,
visible: visible,
uischema: uischema,
renderers: renderers,
};

return (

<AccordionSummary expandIcon={}>
{uischema?.label}


<MaterialLayoutRenderer {…layoutProps} />


);
};

export const groupCollapsibleRendererRegistration = {
tester: rankWith(1000, uiTypeIs(‘Group’)),
renderer: withJsonFormsLayoutProps(MyGroupRenderer),
};

Reference: Custom Layouts - JSON Forms

Kindly let me know, whether this is the expected behavior or what else i can do to disable fields inside group custom layout renderer.

Thanks,
Suseendhiran D

It seems like you are not handing over the enabled prop to the MaterialLayoutRenderer. Therefore the children will not see that their parent was disabled.