Good morning from Gran Canaria.
I´m using solutionModel to create a form that shows buttons based on a table. Buttons should show an image that is stored in a MEDIA field of the table and keep track of the ID for that record.
What I have done is create a label per record, of course positioned on the form as I need, set the name if the label as “lbl_”+recordID (that way I can get the ID of the record in the onAction method of the button). My question is, how can I set the MEDIA field containing the image to the imageMedia property for the label?
Thanks in advance.
OK with this code I´m almost done:
fsFamilias.loadAllRecords();
var _row = 0;
var _col = 0;
var _width = 60;
var _height = 60;
for (var i = 1; i <= fsFamilias.getSize(); i++) {
fsFamilias.setSelectedIndex(i);
// Create the HTML for the media
var _mimeType = 'application/jpeg';
var _fileName = application.getUUID().toString();
var _url = 'media:///servoy_blobloader?servername=gscendepor';
_url += '&tablename=familias';
_url += '&dataprovider=imagen';
_url += '&rowid1=' + fsFamilias.idfamilia;
_url += '&mimetype=' + _mimeType;
_url += '&filename=' + _fileName;
var _html = "<html><img src=\'" + _url + "\'></html>";
var _x = _col + (_col * _width);
var _y = _row + (_row * _height);
var lbl = frmNewForm.newLabel('', _x, _y, _width, _height);
lbl.mediaOptions = SM_MEDIAOPTION.KEEPASPECT;
lbl.text = _html;
_col = _col + 1;
if (_col == 6) {
_row = _row + 1;
_col = 0;
}
}
but now the big problem is that the mediaOptions property is not working. The image is bigger that the label and it is not properly fit.
Any idea?
Hi Juan,
setting the mediaoptions won’t work, as you use html (and that’s no media)
what you should do is setting the size within the html, the only thing is that you might have trouble using different sized images.
there are some useful tips when you google for: ‘html image size aspect ratio’
Hope this helps