Hi,
I am writing a custom function to populate the Choices array within a matrix dynamic question. I have tried several ways of accessing the choices array, I can write a function which populates a dropdown type question though I can't work out how to access the choices array in a matrix dynamic type.
JSON
{
"type": "matrixdynamic",
"name": "Question1",
"title": "Please select your nationality",
"columns": [
{
"name": "nations",
"cellType": "dropdown",
"choices": [
]
}
]
}
JS
function nationality(survey) {
const Question1 = survey.getQuestionByName("Question1")
if(Question1) {
Question1.columns.choices = ['British', 'French', 'German']
}
}
export default nationality;
I have tried
Question1.column.choices = ['British', 'French', 'German']
Question1.nations.choices = ['British', 'French', 'German']
Hello Helen,
Please use the following code:
Question1.getColumnByName("nations").choices = ["Your choices"];
Thank you,
Andrew
SurveyJS Team
Thank you Andrew this works perfectly :)