Disable Rule setting in Layout Schema

Hi Team ,

I have the scenario like when i get the respective value from the drop down other field should have to disable …
eg. Drop down value contains a,b,c .When user select the value C my textbox should have to disable… I have to tried to set the Rule in the Layout schema … But the Rule not applied successfully … Drop Down we are keeping custom Component…

[original thread by Fioyesuraj]

Hi @fioyesuraj(fioyesuraj), please post the schema and ui schema which didn’t work out for you as well as which renderer set you’re using.

[Fioyesuraj]

type:“control”
scope:"#"
options:{booleantext:true}

[Fioyesuraj]

Above code for checkbox …When i change the dropdown value that check box should have to checked …When i change the other value in dropDown it should have to unchecked

[Fioyesuraj]

Scenario 2: when i changed the dropdown value the checkbox should have to change Normal TextBox …When i change the another dropDown value checkbox should change to Dropdown,How to acheive this?

[Fioyesuraj]

you can take is example Rule | JSON Forms 1. When i select a Zombie Is Dead check box should have unchecked .When i select Vampire Is Dead Check box should have to check

Above code for checkbox …When i change the dropdown value that check box should have to checked …When i change the other value in dropDown it should have to unchecked

At the moment rules are only applied visually, i.e. they enable/disable or show/hide ui elements but do not affect the underlying data. Therefore you can’t change the state of a checkbox via the rules support. You can find more information and some solution proposals here: https://spectrum.chat/jsonforms/general/clearing-hidden-fields~93051144-2cd6-47a9-9fe0-cec49ebf42e5

Scenario 2: when i changed the dropdown value the checkbox should have to change Normal TextBox …When i change the another dropDown value checkbox should change to Dropdown,How to acheive this?

You can “fake” this via rule support by hiding and showing different text and boolean controls. Visually it will look like the control changed but actually they are two different controls. However you will have two different data entries then.

If you’re fine with combinators you can solve this in a clean way via oneOfs instead of via rules. However instead of a drop down JSON Forms will render it as tabs.

If that’s not an option then you need either:

  • use a custom renderer which renders a string/boolean depending on the enum value, or

  • exchange schema and data on enum change to replace the string value with a boolean or vice versa

[Fioyesuraj]

In code wise how to update the Ui schema … using JsonFormAngularService?

[Fioyesuraj]

We should not fake the field … We need to change the same field name with different fields

I see, I wasn’t aware that you’re using the Angular renderers. They don’t yet support the oneOf constructs. In that case you will have to add a custom renderer which can handle your special use case. Still I would probably model this as a oneOf.