Formio DataGrid disabled checkbox conditionaly

40 views Asked by At

Hello i don't found solution to my problem, i have 2 case on a datagrid **first case : ** my checkbox "key": "multiValued" (look jsonForm) is disabled: true by default for existing data but when i click on +add button it is disbled true too by default and in my case i want this are disabled: false to be able to select for all new row added.

**Second case: ** my checkbox "key": "required" (look jsonForm) are disabled : false by default but i want Only for existing data

  • if value of row.required is true checkbox need to be disabled : false
  • if value of row.required is false checkbox need to be disabled : true and for new Row added by +add button "key": "required" checkbox need to be disabled : false

my jsonForm :

{
  "type": "form",
  "display": "form",
  "title": "Metadata group",
  "components": [
    {
      "type": "checkbox",
      "label": "Show advanced options",
      "key": "_showOptional_",
      "input": true,
      "tableView": false
    },
    {
      "label": "Collection",
      "labelPosition": "left-left",
      "labelWidth": 30,
      "key": "collection",
      "input": true,
      "tableView": true,
      "inputType": "text",
      "hidden": true,
      "defaultValue": "all",
      "clearOnHide": false,
      "type": "select",
      "validate": {
        "required": true
      },
      "dataType": "string",
      "dataSrc": "url",
      "valueProperty": "name",
      "data": {
        "url": "http://localhost:8080/services/dms/api/sys/docs/main-solr-configs",
        "headers": [
          {
            "key": "Accept",
            "value": "application/json, text/plain, */*"
          }
        ]
      },
      "disabled": true,
      "template": "<span>{{item.relData.config_s}}</span>"
    },
    {
      "type": "datagrid",
      "key": "fieldRefs",
      "initEmpty": true,
      "addAnother": "Add",
      "hideLabel": true,
      "reorder": true,
      "components": [
        {
          "label": "Metadata",
          "labelPosition": "left-left",
          "labelWidth": "0",
          "key": "schemaField",
          "input": true,
          "tableView": true,
          "inputType": "text",
          "type": "select",
          "dataType": "string",
          "dataSrc": "url",
          "valueProperty": "name",
          "data": {
            "url": "http://localhost:8080/services/dms/api/sys/types/schema-field/labels?fq=collection:({{data.collection}} OR all)",
            "headers": [
              {
                "key": "Accept",
                "value": "application/json, text/plain, */*"
              }
            ]
          }
        },
        {
          "label": "Required",
          "dataGridLabel": false,
          "tableView": true,
          "defaultValue": false,
          "key": "required",
          "type": "checkbox",
          "labelPosition": "left-left",
          "labelWidth": "0",
          "input": true
        },
        {
          "label": "Multivalued",
          "dataGridLabel": false,
          "tableView": true,
          "defaultValue": false,
          "key": "multiValued",
          "type": "checkbox",
          "labelPosition": "left-left",
          "labelWidth": "0",
          "input": true,
          "disabled": false
        }
      ],
      "input": true,
      "tableView": false,
      "label": "Data Grid"
    },
    {
      "label": "Form properties",
      "labelPosition": "left-left",
      "keyLabel": "Property",
      "addAnother": "Add",
      "tableView": "false",
      "key": "formProperties",
      "type": "datamap",
      "input": "true",
      "valueComponent": {
        "type": "textfield",
        "key": "",
        "label": "Value",
        "input": "true",
        "hideLabel": true,
        "tableView": "true"
      },
      "customConditional": "show = data._showOptional_ === true"
    },
    {
      "type": "button",
      "label": "Submit",
      "key": "submit",
      "disableOnInvalid": true,
      "input": true,
      "tableView": false
    }
  ]
}

and here the render form : render form Formio with my JsonForm

I have tried lot of solutions

CustomConditional or LogicJson but maybe in wrong way! .

0

There are 0 answers