View array of objects as nested datagrid

0
Hello, I imported the following JSON structure (shortened): There is a Task object which can have an array of 0..n Links. In the Link there is the “OppositeId” which points to the “Id” of the Task object that is linked to Task {   "Fields": { ...     "Id": 1,     "Name": "2020.09.22",     "Label": "2020.09.22",    ...   "Links": [     {       "LinkEndType": "Source",       "LinkId": 1,       "OppositeId": 2,     },     {       "LinkEndType": "Source",       "LinkId": 2,       "OppositeId": 3,     }   ] } The datamodel looks like follows How can I show them in a datagrid? I mean above show the Task and its Fields and below a  There are no associations available to Links   When I load Links by database it shows all links (and way to much, every time I reload the page they get more) When I try with XPath I get no results   The complicated thing is that Task has a sub object “Fields” , and “Links” What I want to achieve is something like in our existing app:   I m afraid that the subject is too complicated to explain here in the forum. We are here at Siemens Industry Software to evaluate if Mendix could be useful for some new user interfaces for parts of our software. Is there andy technical help at Mendix to get a Live Meeting or something? Regards, Raimund    
asked
2 answers
0

Hi Raimund,

Because the association between Task and Links is 1—1, you can’t use a Datagrid, you need to use a Dataview.  So to display the data on a page, you would need

  • a top level Dataview pointed to the UserInputTask entity
  • Inside of that, you would need a Listview pointed to Task via association
  • Inside of this Listview, you should add a Dataview pointed to Links via the association between Task and Links
  • Finally, inside of your Dataview you can place a Datagrid pointed to Link.

Hope that helps,

Mike

answered
0

Raimund, looks like you automatically mapped your import mapping to domain model. I think you can remove the ‘Links’ entity from your import mapping as it's probably optional. Remove it from the domain model as well and attach Link directly to Task in the domain model and then in your mapping and datagrid select this new association.

To not get additional links everytime you call your screen you need to select ‘Find by Key’ in the imortmapping for Link. Select LinkId and OppositeID as key and Mendix will try to return and if not found you can select to create it , like so:

 

answered