In order to display images within a ListGrid I am overriding the getValueIcon method, instantiating an image via Img.create and then returning the result which is being correctly displayed in the grid.
Because the size of the images being displayed varies quite considerably, I am calling setting the width and height against the field parameter as shown in the following snippet:
What I would like to do, to maintain the aspect ratio of the images, is to set the width and height according to the original width and height as per the jpg source. Is it possible to determine the actual size of the source image?
Because the size of the images being displayed varies quite considerably, I am calling setting the width and height against the field parameter as shown in the following snippet:
Code:
getValueIcon: function( field, value, record ) { var result = this.Super( "getValueIcon", arguments ); if ( field.type == "binary" ) { // We need to use the appropriate image based on the table name and id number var imageForRecord = Img.create ( { autoFit: true, src: Page.getAppImgDir() + recordsGrid.dataSource.tableName + "/" + record.id, autoDraw: false, overflow: true } ); field.valueIconWidth = 100; field.valueIconHeight = 70; result = imageForRecord; } return result; }