surveyjs / survey-creator

Scalable open-source survey software to generate dynamic JSON-driven forms within your JavaScript application. The form builder features a drag-and-drop UI, CSS Theme Editor, and GUI for conditional logic and form branching.
https://surveyjs.io/open-source
Other
900 stars 372 forks source link

Set Editor Properties Value #354

Closed cracki closed 6 years ago

cracki commented 6 years ago

How i can set Property value?

For example i want to set "showQuestionNumbers" to "off" by default

Survey.JsonObject.metaData.findProperty("survey", "showQuestionNumbers")

How to set it? Thank you

andrewtelnov commented 6 years ago

@cracki Survey.JsonObject.metaData.findProperty("survey", "showQuestionNumbers").default = "off"; However, it would only tells survey do not serialize showQuestionNumber with property "off". You must to override the getter of the showQuestionNumbers property. It can be done, thanks to JavaScript magic. Here is the example

cracki commented 6 years ago

thank you i want to set "off" the value in editor mode.

default = "off" not worked

andrewtelnov commented 6 years ago

Sure, I wrote it would not work. You have to override getter. Have you copied the code for overriding property in plunker I gave?

Thank you, Andrew

cracki commented 6 years ago

yes i copy plunker codes i get: "TypeError: this.getPropertyValue is not a function"

andrewtelnov commented 6 years ago

@cracki It works fine for me, here is the form bulder example

Thank you, Andrew

cracki commented 6 years ago

Thank You 👍

irshadnilam commented 6 years ago

Hi @andrewtelnov Hi, I am following this example to integrate the editor with React.

And I want to hide question number like @cracki wanted. I couldn't get it working using the plunker example because 'Survey' object is not defined in the component.

I tried to import Survey from 'survey-react'. But it didn't do the trick. Can you tell me what am I missing here?

Thanks

andrewtelnov commented 6 years ago

@irshadnilam Please use this repo to start with react.

Thank you, Andrew

irshadnilam commented 6 years ago

@andrewtelnov I am using that repo as I've mentioned above. I want to achieve what the original poster did using react.

dmitry-kurmanov commented 6 years ago

@irshadnilam I've tried to add the code above to react quickstart repo and it works ok for me.

Please check this code : https://github.com/surveyjs/surveyjs_react_quickstart/blob/master/src/App.js#L256

we have link to Survey object here and it exist