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
923 stars 378 forks source link

Property Item Value visibleIf Not Working #1092

Open ghost opened 3 years ago

ghost commented 3 years ago

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

Bug

What is the current behavior?

Property Item Value visibleIf Not Working

What is the expected behavior?

https://surveyjs.io/Examples/Survey-Creator?id=dependsonproperties&theme=bootstrap#content-js Hiding a new field added with item value, as in the example

Survey .Serializer .addProperty("itemvalue", { name: "dateFormat", dependsOn: ["text"],
visibleIf: function() { return false; } });

ghost commented 3 years ago

dependsOn: ["title"], Also this doesn't work either

tsv2013 commented 3 years ago
Survey.Serializer.addProperty("text", 
    {name: "isRequired:switch", 
       dependsOn: ["readOnly"], visibleIf: (obj) => {return !obj.readOnly}
    }
);

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

ghost commented 3 years ago

Hello, thanks for the return. But addProperty("itemvalue",..) does not work at this value. Your example is different.

tsv2013 commented 3 years ago

Do you want to conditionally hide this column in the choices editor? image

ghost commented 3 years ago

Yeah, I want to hide it conditionally.

I can connect different properties. But he doesn't listen to her

I solved it this way. but it's not dynamic.


Survey
    .Serializer
    .addProperty("question", {
        name: "tag:number",
    });

      Survey.Serializer.addProperty("itemvalue", {  name: "price:number" });
      Survey.Serializer.addProperty("itemvalue", {  name: "tag:number" });
      creator.onCanShowProperty.add(function (sender, options) {
        if (!!options.parentObj && options.property.name == "price") {
          options.canShow = options.property.tag == "10";
        }
        if (!!options.parentProperty && options.property.name == "tag") {
          options.canShow = options.parentProperty.name == "rows";
        }
      });

What I want to do is add the show hide option.

tsv2013 commented 3 years ago

This scenario is not supported in SurveyJS Creator v1.x.x We'll support it in v2 of SurveyJS Creator