hello Team,
We would like to change default option values on dropdown/checkbox/radio button. The approach I am using right now is
surveyBuilder.onQuestionAdded.add(function(sender, options) { options.question.title = "Untitled " + options.question.getType() +". Please enter question title here."; if(["radiogroup", "checkbox", "dropdown"].includes(options.question.getType()) && Array.isArray(options.question.choices)){ options.question.choices.forEach((choice, index) => { choice.value =
Insert option ${index} here.; }); } });
But this has issues when copying questions. This is overriding the copying items
Sorry, could you please explain the issue in more detail? I did not get it.
Thank you,
Andrew
SurveyJS Team
I was trying to update "item1, item2, item3" to some custom text. In order to achieve that I was using
onQuestionAdded
callback to update values. But, the problem with this approach is, when user uses clone question from builder, items are removed and set to defaults I used ononQuestionAdded
callback.So to simplify, How can I customize the item vales on form builder when a question is added?
Got it. You can check, if there are 3 items and their values are "item1", "item2" and "item3".
Thank you,
Andrew
SurveyJS Team
Is there a way to find out if its a clone or drag-drop?
Unfortunately,
creator.onModified
event will be fired after. You can replace the toolbox items jsons. Here is the example that actually shows exactly what you need - overrides choices for dropdown/checkbox/radiogroup.Thank you,
Andrew
SurveyJS Team
Frankly, this is what I need :D
Hello,
As I understood the problem is resolved. Fine! Feel free to contact us in case of any further questions
Thanks, Alex
SurveyJS Team