Skip to main content
September 20, 2021
Question

gridRowLayout conditionl contents

  • September 20, 2021
  • 12 replies
  • 1 view

Hi,

Is there any way to display textField/radioButtonField 's in gridRowLayout based on satisfying given condition ? I have a column, it can be of either dropdown or text field or radiobutton. Type of row has to be decided based on column header selection (column header selection happens dynamically). I have tried using required option but its not working. 

 a!gridRowLayout(
contents: {
a!dropdownField(
labelPosition: "COLLAPSED",
placeholder: "Please select one",
choiceLabels: {"A","B","C","D"},
choiceValues: {"A","B","C","D"},
value:"",
saveInto: a!save(ri!answerList.answerValue,save!value),
required: exact(fv!item.type = "grid",true(),false()),
disabled: rule!APN_isTrue(ri!isReadOnly)
),

a!radioButtonField(
value: "",
choiceLabels: {"False", "True"},
choiceValues: {false, true},
saveInto: a!save(local!gridQuestionsList.defaultAnswer,save!value),
required: if(fv!item.type = "radio button",true(),false())

)

}

)

12 replies

stewart.burchell
September 20, 2021

the 'required' attribute simply forces the user to enter a value. If you want the component to be invisible based upon some criteria then you should use the 'showWhen' attribute which takes a Boolean value.

Note also that you do not need to construct your code as:

if(fv!item.type = "radio button",true(),false())

...since just having:

fv!item.type = "radio button"

will return either "true" or "false".

September 20, 2021

Thanks [mention:7628077af4b9463e9533a897fad2351f:e9ed411860ed4f2ba0265705b8793d05].
When I modify as per your suggestion, am getting below error.

Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!gridLayout [line 13]: A grid layout component [label=""] has an invalid value for "rows". Every row layout must have the same number of components and it must match the number of header cells. The row at index 1 has 3 component(s). Expected: 4 component(s).

stewart.burchell
September 20, 2021

Yes. If you want to hide/show a component in a row you need to ensure the set of header cells matches the number of components in your row. So the same rule could be used on the 'showWhen' attribute on the relevant header cell.