Showing the image of an object in the data grid table

0
My objects have all an image (like a profile photo) and I want to show them in the data grid like the attributes. How can I do that? In my case I have a data grid with a different entity which is associated to the image entity. In this specific data grid want to view the related image.
asked
4 answers
4

Hackish solution:

Extract GUID for System.image derived entity into extra attribute using java:

return String.valueOf(this.par_obj.getId().getGuid());

Add collumn to datagrid with GUID attribute printed out. (say collumn 5);

Use the following CSS to hide the text of that collumn:

td.mx-name-column5{
    font-size:0px;
    color:rgba(0,0,0,0.0);
}

Use the following continually executing java script to add backgrounds to the td that are the images of the System.Image:

var intervalID = setInterval(function(){
    var a=$("td.mx-name-column5");
    for(var i=0;i<a.length;i++){
        var str_GUID=$(a[i]).attr("title");
        var str_imgURL="http://localhost:8080/file?guid="+str_GUID+"&thumb=true&changedDate=1462275795622";
        var str_CSS="background:url(\""+str_imgURL+"\");background-position:top left;background-size:auto 100%;background-repeat:no-repeat;";
        $(a[i]).attr("style",str_CSS); 
        console.log(str_CSS);
    }
}, 500);

End result: alt text

answered
2

Hi Shabbaz,

This is all explained here: https://world.mendix.com/display/public/howto6/Working+with+images+and+files

Edit: If you have the dataview selected in the modeler you can place a second dataview into it. You should now see the association to the image entity. If I remember correctly you can pretty much drag & drop the image entity on this nested dataview.

Cheers, Gonzo

answered
0

The short answer to your question is "No, you can't." Data grids are intended to display a lot of simple data in a table, which definitely does not include images.

Your best bet is most likely to replace your data grid with a list view. As long as you keep you list view at a single line you should have much the same effect. You can then use an image viewer in exactly the same way you would in a data view.

answered
0

Thanks all, I found out that the Template Grid offers the best solution. It looks more like the Data grid than the List view. Thanks again for helping and sharing info.

Cheerz.

answered