surveyjs / survey-creator

Scalable open-source survey software to generate dynamic JSON-driven forms within your JavaScript application. The form builder features a drag-and-drop UI, CSS Theme Editor, and GUI for conditional logic and form branching.
https://surveyjs.io/open-source
Other
922 stars 376 forks source link

Dynamic Matrix is missing from a list of available questions in the condition builder UI #6093

Closed JaneSjs closed 3 days ago

JaneSjs commented 1 week ago

Implemented

Since Survey Creator v1.12.11, you can enable the logic.includeComplexQuestions property in global settings if you want to make matrices, Dynamic Panel, and Multiple Textboxes available in the condition builder UI:

import { settings } from "survey-creator-core"
settings.logic.includeComplexQuestions = true;

History

T20733 - Dynamic matrix question is not showing while adding logic conditions to other questions https://surveyjs.answerdesk.io/internal/ticket/details/T20733


A matrix can be used in exressions: for instance, to check whether a matrix is not empty.

{matrix} notempty

image Consider a demo survey JSON:

{
  "logoPosition": "right",
  "pages": [
    {
      "name": "page1",
      "elements": [
        {
          "type": "matrixdynamic",
          "name": "question1",
          "columns": [
            {
              "name": "Column 1"
            },
            {
              "name": "Column 2"
            },
            {
              "name": "Column 3"
            }
          ],
          "choices": [
            1,
            2,
            3,
            4,
            5
          ]
        }
      ]
    },
    {
      "name": "page2",
      "elements": [
        {
          "type": "radiogroup",
          "name": "question2",
          "choices": [
            {
              "value": "Item 1",
              "text": "Yes"
            },
            {
              "value": "Item 2",
              "text": "No"
            }
          ]
        },
        {
          "type": "matrixdynamic",
          "name": "question3",
          "columns": [
            {
              "name": "Column 1"
            },
            {
              "name": "Column 2"
            },
            {
              "name": "Column 3"
            }
          ],
          "choices": [
            1,
            2,
            3,
            4,
            5
          ]
        }
      ]
    }
  ],
  "triggers": [
    {
      "type": "copyvalue",
      "expression": "{question2} = 'Item 1' and {question1} notempty",
      "fromName": "question1",
      "setToName": "question3"
    }
  ]
}

However, the condition editor doesn't display a matrix in a list of available form elements: image

JaneSjs commented 1 week ago

@andrewtelnov, a matrix doesn't appear in a list. Instead, [object] appears. View Demo image Please check.