How do I set the row visibility in the form when the boolean is in another entity?

2
There is entity Student with attribute Score. Another entity Course with attribute IsScorable. Many Student can associate to one Course. In dataview of Student I want display the Score only if the Course associated to the Student has IsScorable=true. The association of Student_Course is unidirectional from Student. How do I set the visibility in the form of Student edit? The dilemma is that when I use a table for its row visibility in Student dataview it is not able to see the Course to find the visibility condition. Inner dataview is also not helping.
asked
6 answers
3

Just add isScorable to Student as a calculated attribute. In the microflow retrieve the Course by association and return Course/IsScorable. Now you can conditional display your row :)

answered
1

Several different ways to skin this one. If I am correct in assuming that a student can be in more than one course, you could do the following:

  • If you just want to display scores, you could put a nested datagrid inside of your student dataview, datasource would follow the association between Student and Course and then you would use XPath to limit the displayed objects to only those courses with IsScorable = true

  • if you want to edit scores, its a bit more complex. Use a nested TemplateGrid with same datasource and xPath as the datagrid described above. In the rows of the TemplateGrid, use a FormLoader (from the appstore) that loads a form with the course name and grade and has commit microflows on each editable field to commit the changes

hope that helps.

answered
1

The row visibility boolean will only work with attributes of the entity you are using in your form - not with any associated entities. So you'll need to build your form to account for this. One way would be a slight modification of my previous answer:

  • Create Student dataview form
  • Create Course dataview form with Course Name row and Score Row
  • In Student form, create a nested template grid that displays courses a student is in via the Student---Course association
  • in the nested template grid, use a form viewer that calls the Course dataview form created earlier

This will enable you to use the row visibility on the Course dataview form to show or hide the Score field.

answered
0

Mike, How should i go about if a Student takes only one Course. (my actual app with different entities does not have many-to-many)? The summary of my question is that my attribute and the boolean that decides visibility are in separate entity..so am not able to use row-visibility in dataview. No grid is involved in my problem.

answered
0

Actually, my form has a specific need to control visibility of a field. Only issue being that the boolean that determines its visibilty lies in another entity associated to the main entity. So I dont know how to use row visibility for this situation, because the row visibility wont let me select a boolean that exists in a other associated entity.

answered
0

Mike and others who replied, Thanks for replies and explanations. I would like to add that I found a simpleton solution for my problem above. What i did was to make a data view of Course inside Student dataview. Then made a table and row with visibility criteria in that dataview. Inside that restricted-visibility-row, i put a new dataview whose source is from microflow. And this microflow gets called with Course (self) and also the parent i.e. Student...so in that microflow i dont have any activity but just return that Student from microflow. That is used as datasource of that embeded dataview of Student. And then I can add a text field for the attribute Score..and all this inside the restricted-visibility-row. Mendix climbed up in my favorite chart.

answered