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

Expressions: Add an API to access a display text associated with any value rather than with the current question value #8576

Closed
andrewtelnov opened this issue Jul 18, 2024 · 0 comments
Assignees
Milestone

Comments

@andrewtelnov
Copy link
Member

andrewtelnov commented Jul 18, 2024

IMPLEMENTED

Since SurveyJS v1.11.8, the displayValue function supports a second parameter that can be used to get a display text associated with any question value. For instance, the following expression references a display text that corresponds to value 5 in a Dropdown question.

"expression": "displayValue('my-dropdown-question', 5)"

Documentation


You may need to get the display value based on value that are not set to the question. Please review the following JSON:

{
    elements: [
      {
        type: "checkbox",
        name: "q1",
        choices: [{ value: 1, text: "Item check 1" }, { value: 2, text: "Item check 2" }, { value: 3, text: "Item check 3" }]
      },
      {
        type: "dropdown",
        name: "q2",
        choices: [{ value: 1, text: "Item 1" }, { value: 2, text: "Item 2" }, { value: 3, text: "Item 3" }]
      },
      {
        type: "matrixdynamic",
        name: "matrix",
        columns: [
          { cellType: "text", name: "col1" },
          { cellType: "expression", name: "col2", expression: "displayValue('q1', {row.col1})" },
          { cellType: "expression", name: "col3", expression: "displayValue('q2', {row.col1})" }
        ]
      }
    ]
  }

The expressions values are based on row cell value & 'q1' and 'q2' settings.

@andrewtelnov andrewtelnov self-assigned this Jul 18, 2024
@RomanTsukanov RomanTsukanov changed the title Add value as a second parameter into 'displayValue' function Expressions: Add an API to access a display text associated with any value rather than with the current question value Jul 22, 2024
@OlgaLarina OlgaLarina added this to the v1.11.8 milestone Jul 22, 2024
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