https://codesandbox.io/s/surveyjs-angular-forked-2rpp8v
Dear Support Team,
I hope this message finds you well. I am writing to report an issue I have encountered with the RequiredIf
condition set for in our system.
Description of the Issue:
- When I enter a value in any single row of
col1
, theRequiredIf
condition forcol3
is not being displayed as expected. - The
RequiredIf
forcol3
only appears if every row incol1
has a value, rather than when any single row incol1
is filled.
Expected Behavior:
- The
RequiredIf
condition forcol3
should be triggered if any row incol1
is not empty, irrespective of the other rows incol1
.
In the attached image
- Entering "value1" in the first row of
col1
should trigger theRequiredIf
condition forcol3
Current Behavior:
- The
RequiredIf
condition forcol3
does not display unless all rows incol1
are filled.
Thank you
Ram
Hi Ram,
Thank you for sharing a demo. Unfortunately, I was unable to access a CodeSandbox demo for some reason. If you wish to enable the required column option when another column's cell receives a value, use the
{row.XXX}
prefix as follows:{row.Column 1} notempty
. Consider the following sample survey:{ "pages": [ { "name": "page1", "elements": [ { "type": "matrixdynamic", "name": "question1", "columns": [ { "name": "Column 1" }, { "name": "Column 2", "requiredIf": "{row.Column 1} notempty" } ], "choices": [ 1, 2, 3, 4, 5 ], "cellType": "text" } ] } ] }
Enter a value within the first row's Column 1 and you'll see that the Column 2 cell within the first row becomes required.
Let me know if it works for you.
Hi Jane,
Thanks for your reply!
The issue is little weird. I have setup both visibleIf & requiredIf condition on a column of matrix as mentioned in the shared JSON.
When I am launching the preview & after providing the value in the Column1 to satisfy the condition, Column 3 is getting visibled but asterisk for requiredIf is not coming for that column even tough visibleIf & requiredIf are having same condition in the logics.
When I am trying to satisfy the condition in the second row then the asterisks is appearing for the Column3.
It is reproducible in Survey Creator Demo as well. Below is the JSON you can use for reference.
{ "logoPosition": "right", "pages": [ { "name": "page1", "elements": [ { "type": "matrixdynamic", "name": "question1", "columns": [ { "name": "Column 1", "cellType": "text" }, { "name": "Column 2", "cellType": "text" }, { "name": "Column 3", "cellType": "text", "visibleIf": "{row.Column 1} notempty", "requiredIf": "{row.Column 1} notempty" } ], "choices": [ 1, 2, 3, 4, 5 ] } ] } ] }
Thanks,
Ram
Hello Ram,
Thank you for the update. The condition works row-wise. Therefore, when you enter a value within the first row, only the first row cell of Column 3 becomes required. The second row of Column 3 is not required. Therefore, an asterisk doesn't appear. However, the asterisk appears when you enter a value within the second row because now all rows of Column 3 are required. Please let me know if this clarifies the situation. Also, let me know if you would like to add some indication to individual matrix cells.
Thank you