I want to create a SurveyJS matrix with rows that contain a text & HTML element. Thus, the HTML content should change in each row. The Survey is a reasoning test that contains a text statement and a symbol pattern that I create by combining HTML code with some CSS. In the remaining columns it contains the response if the statement correctly describes the symbol pattern.
Below is an example of creating the matrix with the correct column types and row information. If I pass a static HTML to the HTML column it gets displayed correctly. But I am stuck at accessing the pattern property of each row to dynamically change the HTML.
const matrix_dynamic_html = {
"elements": [
{
type: "matrixdropdown",
name: "Test",
title: "my_title",
description: "my_pattern",
columns: [
{
name: "pattern",
title: "Pattern",
cellType: "html",
// here we have to access the HTML for each row
html: "{row.pattern}"
},
{
name: "response",
title: "response",
cellType: "radiogroup",
"choices": [
{
"value": 0,
"text": "Incorrect"
},
{
"value": 1,
"text": "Correct"
}
],
"showInMultipleColumns": true,
"colCount": 1
}
],
rows: [
{
value: "question_1",
text: "This is question 1.",
pattern: generate_html("ques_1"),
},
{
value: "question_2",
text: "This is question 2.",
pattern: generate_html("ques_2"),
},
{
value: "question_3",
text: "This is question 3.",
pattern: generate_html("ques_3"),
},
{
value: "question_4",
text: "This is question 4.",
pattern: generate_html("ques_4"),
}
],
rowTitleWidth: "50%",
}
],
"showQuestionNumbers": false
};
I use the generate_html function to generate the HTML and have checked that this works properly.
I appreciate any input on how to access the pattern property or adapt the setup of the matrix to be able to dynamically change the HTML. Any help is welcome.