Hi,
Actually I using two questions. one question is radio group. second question is dynamic penal. So inside dynamic panel I added two questions like question3 and question4. the question3 visible when question1 answer Item 1.
I default set data for question1 is Item 2 and I added 'and' condition true or false flag like,
for example, {question1} = 'Item 2' and true
So the basic condition is failed. but when I check the question isvisible flag the question3 isvisible flag return true but i want false and isvisible flag return true everytime if visbleif condition fails or pass, but in UI not display. Could you please give any solution for get what are question display in UI based on visible if? please help here. Thanks.
Hello Swathi,
I created the following demo based on your explanation: https://plnkr.co/edit/0dlzxjjfBy3g41lz.
The
question3
is visible or hidden based on thequestion1
(Radiogroup) question value and the value of avar1
survey calculated field:{ "type": "text", "name": "question3", "visibleIf": "{question1} = 'Item 1' and {var1} = true" }
The complete survey JSON is available below.
const json = { "logoPosition": "right", "pages": [ { "name": "page1", "elements": [ { "type": "radiogroup", "name": "question1", "defaultValue": "Item 2", "choices": [ "Item 1", "Item 2", "Item 3" ] }, { "type": "paneldynamic", "name": "question2", "templateElements": [ { "type": "text", "name": "question3", "visibleIf": "{question1} = 'Item 1' and {var1} = true" }, { "type": "text", "name": "question4" } ], "panelCount": 1 } ] } ], "calculatedValues": [ { "name": "var1", "expression": "true" } ] }
Please let me know if this example works as expected.
Do you wish to determine whether
question3
is actually visible or not? Would you please clarify how you wish to use this information?Do you wish to determine whether
question3
is actually visible or not? Would you please clarify how you wish to use this information?Sure, Actually I using 3 types of questions. the second type some questions display based on first type of question. once first type of question answered. i need to validated any second type of question display or not. If second type not present in UI I need to validate third type of questions. That's why I need to check how to get list of displayed and undisplayed questions based on visible if condition.
Could you please give any solution for this.
Hello Swathi,
Thank you for the clarification. I recommend that you try the survey.onQuestionVisibleChanged event to complete your task. Subscribe to this event to determine when a question's visibility has changed. At this point, you can check
options.question
against the target question, and check its visibility using theoptions.visibility
parameter.Please let me know if this function helps.
Hi Jane,
But onQuestionVisibleChanged event when question visibility changed that time only this event trigger. But I need to check all questions initial loading time. could you give any solution get all visible questions in UI not a hide questions
Hello,
May I know how exactly you wish to use the visibility of a question by the time you load a survey? Please share an example of usage.
Hi,
actually I already told three type of questions. I am using three different screens. So that when I am loading survey and result json. That time I need to validate which questions are displayed based on visibleif condition.
for example I am in first page first type of questions only display I answer it and I click save. The page move to next page here I can display first type of question read only mode and second question display when complete. I move to next page some progress. So here when I am first place and save I need to check if any questions are display or not based on visibleIf condition. if available I need to move second page. if not available I need to check third type question visible or not based on visibleIf condition.
So I need to check all question every time. This is my scenario. Could you please tell how to get visible and hidden questions? when page load that time I need to validate this things.
Hello Swathi,
You can check a question's isVisible option to determine whether or not a question is visible.
If a question is located inside a dynamic panel, you can get a panel instance and obtain a question instance from it. For example:
const panel = survey.getQuestionByName('panelDynamicQuestion'); let question3 = panel.panels[0].getQuestionByName('question3'); let questionIsVisible = question3.isVisible ...
https://plnkr.co/edit/viTi5LXY6bGq1wzQ?preview
Please let me know if this option suits you.