Cart Buy Licenses Contact Integrate into App Docs Support Login/Register
v 1.8.72
v 1.8.72
Overview Survey Creator Examples Docs Source Download

Properties that depends on other properties

Hide/Show property or change its choices based on other properties


//This property is depends on date format property of text question
//It is invisible if inputFormat property doesn't equal to "date*" values
Survey.Serializer.addProperty("text", {
name: "dateFormat",
dependsOn: ["inputType"],
visibleIf: function(obj) {
    return (
    obj.inputType == "date" ||
    obj.inputType == "datetime" ||
    obj.inputType == "datetime-local"
category: "general",
visibleIndex: 7
Survey.Serializer.addProperty("question", {
    name: "targetEntity",
    choices: ["", "Account", "Developement"],
    category: "Entity",
    categoryIndex: 1
//This property depends from targetEntity property.
//If targetEntity property is empty then choices for targetField are empty as well.
Survey.Serializer.addProperty("question", {
    name: "targetField",
    dependsOn: "targetEntity",
    category: "Entity",
    choices: function(obj) {
        var choices = [];
        var entity = !!obj ? obj.targetEntity : null;
        //If targetEntity is empty then return the empty array
        if (!entity) return choices;
        //The correct way to set the nullable value
        choices.push({ value: null });
        choices.push(entity + " 1");
        choices.push(entity + " 2");
        choices.push(entity + " 3");
        return choices;
Survey.Serializer.addProperty("survey", {
    name: "region",
    choices: ["Africa", "Americas", "Asia", "Europe", "Oceania"],
    category: "Geo Location",
    categoryIndex: 1
//This property country depends on the selected region.
//It allow to select all countries if region is empty or if it is not empty, only countries from this region
//It uses rest full service and choicesCallback function to tell Survey Creator property editor that choices are loaded from the web
Survey.Serializer.addProperty("survey", {
name: "country",
dependsOn: "region",
category: "Geo Location",
choices: function(obj, choicesCallback) {
    //We are going to use choicesCallback here
    var xhr = new XMLHttpRequest();
    //if region is empty then get all countries, otherwise get coutries by region.
    var url =
    !!obj && !!obj.region
        ? "" + obj.region
        : "";"GET", url);
    //on load event set results into array of ItemValue and tell the Survey Creator that choices are loaded.
    xhr.onload = function() {
    if (xhr.status === 200) {
        var serverRes = JSON.parse(xhr.response);
        var res = [];
        //We will use ItemValue array here, since we want to have value different from display text
        res.push({ value: null });
        for (var i = 0; i < serverRes.length; i++) {
        var item = serverRes[i];
        res.push({ value: item.alpha2Code, text: });
        //return the result into Survey Creator property editor
                var creatorOptions = { };
                var creator = new SurveyCreator.SurveyCreator("creatorElement", creatorOptions);
                creator.showToolbox = "right";
                creator.showPropertyGrid = "right";

<!DOCTYPE html>
<html lang="en">
    <title>Hide/Show property or change its choices based on other properties, Survey Creator Example</title>

<meta name="viewport" content="width=device-width" />
    <script src=""></script>
    <script src="/DevBuilds/survey-knockout/survey.ko.min.js"></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>
        <script src="/DevBuilds/survey-creator/survey-creator.min.js"></script>
        <link href="/DevBuilds/survey-creator/survey-creator.min.css" type="text/css" rel="stylesheet" />
    <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>