I have a custom widget which I want to set the titleLocation to hidden and the hideNumber to true by default - but still be able to edit it if I want to in the creator. How do I accomplish this?
How to set a default value to a property in a custom widget
Answers approved by surveyjs Support
Hi Brian,
You can use the Serializer.getProperty('questionType', 'propertyName')
function to obtain target settings of your custom widget and set the defaultValue
attribute:
JavaScriptSurvey.Serializer.getProperty('customWidgetType', 'titleLocation').defaultValue = 'hidden';
Survey.Serializer.getProperty('customWidgetType', 'hideNumber ').defaultValue = true;
Please let me know if this code works for you.
Comments
(2)
Hi,
The following code:
CodeSurveyLib.Serializer.getProperty(
'datasheet',
'showCommentArea'
).defaultValue = true;
This is meant to show the comment area by default, and check the box by default.
However, this is not the case. Am i doing something wrong?
Hello Ahmad,
I created a separate ticket on your behalf: T15355: A comment section does not appear by default. We placed it in our processing queue and will process it shortly.