1 Image from a list aside of a dataview

0
On a page I want to display one image (photo) on the left of the object data it is associated with. First problem is: the object can have more than one images associated with it. In a microflow (MF) I can do a retrieve over an association, but that does not give the option "First record only" (as I think it should be possible). After checking the contents of the list (0, 1 or many entry(ies)) I can create a single object, or loop through the list and remove all but 1 objects. But then I either pass on an object or a list at the end of the MF, which is not possible: the receiving end expects an object only. So, how can I retrieve 1 image of an object from a list and pass it on to the receiving widget on the page?   Second problem: I want to display the image on the left side of the data displayed. Using a layout grid widget I can have the data in a dataview in the right column. But adding an imageviewer (in a dataview) in the left column of the grid does not link the two columns of the link on the object as caller of the page (kind of listen to). Even though the object and its data is available on the entire page due to the dataview in the right column, I cannot have a link to that data from any other widget on the page, unless it is in the same container. And I cannot place a widget left of another widget within the same container.    
asked
3 answers
1

You could solve problem one in two ways:

First method:

Retrieve via the MF use the retrieve by association followed by a "List operation" activity and then choose the operation "Head" this will retrieve the first item in the list which you can then return. You could precede this with a "List operation" action to sort your images and retrieve the "first" one as you mark it first.

Second method:

Use a list view to show encapsulate the image shown. So you would get Data View (with object) > List view (with the association to images) > Data view (for image object). Make sure to only display one image and do not show a search, make the listview editable to prevent a load more button to show. And make the image data view not editable to prevent editing (unless this is wanted of course).

The second problem can be resolved by:

Adding the metadata object view around the layout grid, and thereby encapsulating the full layout grid in which you add two columns within the left column the image and the right column the object data.

 

Hope this helps and wish you much fun with the Mendix platform.

 

answered
0

Thanks for the reply.

Ad 1. Changed the MF using List Operation Head; the error(s) regarding the MF has disappeared.

Ad 2. What do you mean with 'metadata object view'? I cannot find it in the Modeller.

I can run the app locally, but opening the page throws an error and closing the message box the page appears without the photo left of the data.

The page is constructud as:

Lay out grid (caller of the page)

In first row a data view,

in this data view a second lay out grid; left the photo (over association), in the right column data from the calling entity.

In the second row a tab container (caller of the page) .

The data from the calling entity displays in their corresponding widgets/attributes.

The photo (or any widget related to it) does not show up.

I get this error when association between object and photo is 1:n and 1:1.

Any solutions for this would be highly appreciated.

answered
0

You can also create a helper assocation 'person_firstimage' and make a dataview to show that image. Is faster and easier in the form.

answered