Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setValueIf and setValueExpression into question #7076

Closed
andrewtelnov opened this issue Oct 4, 2023 · 0 comments
Closed

Add setValueIf and setValueExpression into question #7076

andrewtelnov opened this issue Oct 4, 2023 · 0 comments
Assignees
Milestone

Comments

@andrewtelnov
Copy link
Member

If a question name or variable or calculated name changed that used in question.setValueIf expression and it returns true then setValueExpression is executed and set the result into the question.value. If setValueExpression is empty then question.clearValue() will be called. You basically can use these properties instead of "setvalue" trigger and it works for matrices and dynamic panel.
Here are some examples of usage:
For root questions:

{
    elements: [{
      "name": "q1",
      "type": "text"
    },
    {
      "name": "q2",
      "type": "text",
      "setValueIf": "{q1} = 1",
      "setValueExpression": "{q1} + {q3}"
    },
    {
      "name": "q3",
      "type": "text"
    }
    ] }

For matrices:

{
    elements: [
      {
        type: "matrixdynamic",
        name: "matrix",
        rowCount: 1,
        columns: [
          { name: "q1", cellType: "text" },
          { name: "q2", cellType: "text", setValueIf: "{row.q1} = 1", setValueExpression: "{row.q1} + {row.q3}" },
          { name: "q3", cellType: "text" },
        ]
      }
    ]
  }
{
    elements: [
      {
        type: "paneldynamic",
        name: "panel",
        panelCount: 1,
        templateElements: [
          { name: "q1", type: "text" },
          { name: "q2", type: "text", setValueIf: "{panel.q1} = 1", setValueExpression: "{panel.q1} + {panel.q3}" },
          { name: "q3", type: "text" }
        ]
      }
    ]
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants