surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.2k stars 812 forks source link

Default values can't be visualized (radiogroup, checkbox, dropdown,boolean) #2813

Open joespinoz opened 3 years ago

joespinoz commented 3 years ago

Are you requesting a feature, reporting a bug or asking a question?

Reporting a bug

When you give a default value to a component like (radiogroup, checkbox list, dropdown or boolean) doesnt work correctly when you try to visualize.

The code of the survey is this:

"definition": { "pages": [ { "name": "página1", "elements": [ { "type": "radiogroup", "name": "pregunta1", "defaultValue": "item1", "choices": [ "item1", "item2", "item3" ] }, { "type": "checkbox", "name": "pregunta2", "defaultValue": [ "item2" ], "choices": [ "item1", "item2", "item3" ] }, { "type": "dropdown", "name": "pregunta3", "defaultValue": "item3", "choices": [ "item1", "item2", "item3" ] }, { "type": "boolean", "name": "pregunta4", "defaultValue": "true" }, { "type": "boolean", "name": "pregunta5", "defaultValue": "false" } ] } ] }

andrewtelnov commented 3 years ago

@ArpaxHerzeck It works fine to me. Here is the example with your JSON. Do you set survey.data = yourData; in your code? it will reset all values. You probably need to use survey.mergeData function, survey.mergeData(yourData);.

Thank you, Andrew