Add properties

Please read the license agreement if you want to use Survey Creator widget in your app(s). Visit our buy page to find out developer license(s) price.
Add a new property to any object

                        //add a property to the survey object
Survey.JsonObject.metaData.addProperty("survey", "tag:number");
//add a property to the page object
Survey.JsonObject.metaData.addProperty("page", {name: "tag:number", default: 1});
//add a property to the base question class and as result to all questions 
Survey.JsonObject.metaData.addProperty("question", {name: "tag:number", default: 0});

var creatorOptions = { };
var creator = new SurveyCreator.SurveyCreator("creatorElement", creatorOptions);

<!DOCTYPE html>
    <title>Add a new property to any object, Survey Creator Example</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src=""></script>
<script src=""></script>
    <script src="" type="text/javascript" charset="utf-8"></script>
    <script src="" type="text/javascript" charset="utf-8"></script>
    <!-- Uncomment to enable Select2
    <script src=""></script>
    <link href="" rel="stylesheet" />
    <script src=""></script>
    <link href="" type="text/css" rel="stylesheet" />
    <script src=""></script>
    <link rel="stylesheet" href="">
    <link rel="stylesheet" href="./index.css">

        <div id="surveyContainer">
        <div id="creatorElement"></div>

<script type="text/javascript" src="./index.js"></script>


Property definition specification

Short definition


Full definition

{name: "propertyName[:propertyType]" [, default: defaultValue][, choices: Array of values]
[, onGetValue: function (obj) { return yourValueFromObject; }]
[, onSetValue: function (obj: any, value: any) {/*perform an action on setting value */ }]}


A property name. If a property name begins with '!', it means the property is required. If the property is not set, the json parser will raise an error. For example, "name" and "type" properties of the question object are required: "!type" - it means that string property "type" is required.


It is an optional attribute. If the value is not set then the library treats it as a string property.
  • string - it is the default value type. Property editor is a text input. "myProperty" and "myProperty:string" - give the same result.
  • boolean - a Boolean type. Property editor is a checkbox.
  • number - a numeric type. Property editor is a text input.
  • text - string type. Property editor is text input with an optional modal window for entering large text.
  • html - string type. Property editor is text input with an optional modal window for entering large text. In the future modal window becomes a very simple html editor.
  • Itemvalues - the array of ItemValue object. ItemValue object has two properties {value: any, text: string}. Dropdown, checkbox and radiogroup questions has choices property with itemvalues type.
  • matrixdropdowncolumns -for matrixdropdown and matrixdynamic columns have this type.
  • texitems - items property of multiple text question has this type
  • triggers - survey triggers property has this type.
  • validators - question validators property has this type.
You are able to introduce your own type and register a new property editor for this new type.


It is an optional attribute. The library do not serialize the default value into JSON. By default, the empty text is default for string value, 0 is for numeric and false for boolean. You may change it by using this attribute.
{ name: "mode", default: "edit"}
{ name: "showTitle:boolean", default: true }


It is an optional attribute. It makes sense for string and numeric property types only. If the choices attribute is set, the property editor for the property becomes dropdown. You may assign the array of values to this attribute or a function that will return the array of strings or numbers.
{ name: "showProgressBar", default: "off", choices: ["off", "top", "bottom"] }
//returns the supported languages in the surveyjs library.
{ name: "locale", choices: function() { return Survey.surveyLocalization.getLocales(); } }


It is an optional attribute. You may assign a function to return a value different from the property value.
// get title property returns a title with question number and so on "5) My super title.", 
//but we want to serialize only a "pure" question title "My super title".
{ name: "title:text", onGetValue: function (obj: any) { return obj.titleValue; } }
// the function always returns null. It means that the library will never serialize the property in JSON.
{ name: "calcProperty", onGetValue: function (obj: any) { return null; } }


It is an optional attribute. You may assign a function to set a different object property and/or perform some actions.

{ name: "myValue", onSetValue: function (obj, value, jsonConverter) {obj.myValue = value; /* Perform some actions */ }}