Hi guys.
I've a cloned control and have custom property for the question base object "iSessions" by default it is false.
1-I want to set this property to true in case the user dropped my custom control called "SpeakersMatrixMultipleChoice"
2-Also I want to hide this custom property from the user while he is trying to build his survey. I don't know how to use the below code.
editor
.onCanShowProperty
.add(function (sender, options) {
if (options.obj.getType() == "survey") {
options.canShow = options.property.name == "title";
}
});
Hello,
There first question is answered here: https://surveyjs.answerdesk.io/ticket/details/t570
Here is the code for the second:
editor.onCanShowProperty.add(function (sender, options) { options.canShow = options.property.name !== "iSessions"; });
Another option, on adding a new property, set its visible attribute, visible: false, like you set the default value to false, default : false.
Thank you,
Andrew
SurveyJS Team
Hi Andrew,
1-The answer at the link is talking about customizing the toolbox not answering the user question which is how to set default value for the entire controls specific property.
I found the answer by setting the property "custom property called iSessions" value for the cloned control in the builder and check how it is rendered as JSON. (attached).
2-Thanks, it is working .
Hi,
Here is the example you are looking for: https://plnkr.co/edit/r2uxsY?p=preview
It is change the default json of the item on the toolbox.
Thank you,
Andrew
SurveyJS Team
Thanks Andrew
var boolItem = editor.toolbox.getItemByName("boolean");
getItemByName method should take the property name ? for example if i want to set isRequired = true for all controls then it should be :
var boolItem = editor.toolbox.getItemByName("isRequired");
boolItem.json = {type: "isRequired", defaultValue: "true"};
I tried the above code but didn't set by default "isRequired" property to true for all controls.
You can also set
isRequired
property to 'true' value in the onQuestionAdded event handler.Thanks, Serge
SurveyJS Team