Question T580
Visible to All Users

how to set a custom property for a cloned question automatic

created 7 years ago

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";
}
});

Show previous comments (2)

    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