Survey-library: Remove 'default' properties from custom widget doesn't work

Created on 10 Mar 2020  路  3Comments  路  Source: surveyjs/survey-library

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

Question/Bug

What is the current behavior?

Using Survey knockout I've created a custom widget myButton , the fact is that I can add a custom property and I can remove it, but Survey is adding some default props that I can't access and I want to remove some of them from only my 'myButton', not for all 'question'.

What is the expected behavior?

If I remove a property from the final object then this property should not exist.

How would you reproduce the current behavior (if this is a bug)?

Create a custom widget, add some property and then see if SurveyKo.JsonObject.metaData.getProperties('myButton') has the default and adedd properties and
try to remove some of default properties like placeholder from 'myButton'.

Test code
import * as SurveyKo from 'survey-knockout';

 SurveyKo.JsonObject.metaData.addClass('myButton',
     [
       { name: 'buttonText', default: 'btn text'},
       { name: 'buttonClickEvent', default: '// Whatever' }
     ],
     null, 'empty');

SurveyKo.JsonObject.metaData.removeProperty('myButton', 'valueName');
const defaultProps = Survey.JsonObject.metaData.getProperties('myButton');
console.log(defaultProps)

This removeProperty should remove the default property but it's not working.

image

image

How can I remove the property only for my widget instead of all question?

Specify your

  • browser: Chrome last
  • surveyjs platform: React 16.12.0
  • surveyjs version:
    - survey-creator: 1.5.10,
    - survey-knockout: 1.5.10,
    - survey-react: 1.5.10,
question

Most helpful comment

You can make certain properties invisible in SurveyJS Creator using the following code:

Survey
    .Serializer
    .addProperty("checkbox", {name: "readOnly", default: false, visible: false});

E.g. this code ovverrides default readOnly property for checkbox question and makes it invisible in SurveyJS Creator

Here is the working sample - https://plnkr.co/edit/lNPaGksHdykFshRj

All 3 comments

Do you want to remove these properties from the SurveyJS Creator?

You can make certain properties invisible in SurveyJS Creator using the following code:

Survey
    .Serializer
    .addProperty("checkbox", {name: "readOnly", default: false, visible: false});

E.g. this code ovverrides default readOnly property for checkbox question and makes it invisible in SurveyJS Creator

Here is the working sample - https://plnkr.co/edit/lNPaGksHdykFshRj

At the first I wanted to eliminate them but if I can hide them it's better, Thank you!!

Was this page helpful?
0 / 5 - 0 ratings