survey-creator
survey-creator copied to clipboard
SurveyCreator. How to get question's custom properties in survey model.
Are you requesting a feature, reporting a bug or ask a question?
Question
What is the current behavior?
I have the custom 'readonly' properties for the questions. In our case there is a 'questionType'. After survey creator was initialized - questionType properties are disappear. When I'm trying to save my survey, there are no questionType properties at all.
What is the expected behavior?
After survey was saved, I would like every question have their own 'questionType' readOnly property. Like in the example. { "type": "rating", "name": "question6", "title": "question6", "questionType": "Regular", "id": "sq_1284" },
I understand, I can't see them in JSON editor, because it's readOnly props, but I also can't get it after survey was saved.
How would you reproduce the current behavior (if this is a bug)?
From the backend I'm getting 'questionType' readOnly property for the each question, but they disappear after when I'm going to save my survey. In the current example - what I've got. { "type": "rating", "name": "question6", "title": "question6", "id": "sq_1284" },
Test URL: https://codesandbox.io/s/hopeful-saha-8wfdtb?file=/src/index.tsx
Steps to reproduce:
- Open the link above.
- Add new question.
- Check console.log with JSON.stringify(model)
Provide the test code and the tested page URL (if applicable) Test URL: https://codesandbox.io/s/hopeful-saha-8wfdtb?file=/src/index.tsx
Specify your
browser: Chrome 102 browser version: 102 surveyjs platform (angular or react or jquery or knockout or vue): React surveyjs version: v1.9.41
@Matvey1308 questionType is not saved bacause it is equal to default value "Regular".
SurveyJS doesn't save property value if it equals to default value. Otherwise JSON for every element would be huge.
You can access the value as: survey.getQuestionByName("myQuestion").questionType.
It should return to you "Regular" string.
Thank you, Andrew