Closed y0n4 closed 1 month ago
Hello @y0n4, Thank you for the comprehensive explanation and demo. To access an item's display text, implement the survey.onGetExpressionDisplayValue and return an items display text instead of a value.
Consider the following code:
survey.onGetExpressionDisplayValue.add((sender, options) => {
if (options.question.name === "carLogic") {
const carBrandQuestion = options.question.parent.getQuestionByName(
"carBrand"
);
const carBrandValue = carBrandQuestion.value;
if (!carBrandValue) return;
const carBrandDisplayText = Survey.ItemValue.getTextOrHtmlByValue(
carBrandQuestion.choices,
carBrandValue
);
options.displayValue = carBrandDisplayText;
}
});
Please let me know if you have further questions.
Are you requesting a feature, reporting a bug or asking a question?
question - is there a way for the expression input to return display text instead of value in json template format?
What is the current behavior?
The expression input returns value which is more like a unique string rather than something to show to users
What is the expected behavior?
We would like to have the expression input return display text for the next question dynamic title
How would you reproduce the current behavior (if this is a bug)?
Provide the test code and the tested page URL (if applicable)
Tested page URL: https://codepen.io/y0n4/pen/ExzjbwE
Test code
Specify your