Image Thumbnails can be created at the design time using list view. But the problem is we can show only one thumbnail per row/line. This is fine as long as the number of thumbnails to be created is known but when the number of thumbnails to be created is not known and there is a need to show the thumbnails in a formatted way, there is only one option ie. to create these image thumbnail objects at run time using Solution Model.
1. To do this first create a run time form object.
var frmObj = solutionModel.newForm(formName, serverName, tableName, styleName, true, width, height);
2. Create media type variables which will work as dataprovider for the media field.
var formVariableObj = frmObj.newFormVariable(variableName, JSVariable.MEDIA);
3. Create form field by using the dataprovider as the previously created form variable.
frmObj.newField(formVariableObj, JSField.IMAGE_MEDIA, x, y, width, height);
4. Show the form.
5. Now the form is created, we need to initialize the dataprovider/variable.
Here variableName : The dataprovider/variable attached to the media field
imageData : The byte of the image.
Note : The last step is very important, which is used to initialize the run time form variables.
– The run time media type variables cannot be initialized to an image data by using the defaultValue property of jsVariable.
formVariableObj.defaultValue = imageData;
– This is because the variable is not created/instantiated at that time. This defaultValue property only works good for the text or integer initialization.
– So you need to initialize the variable(s) after the form is created and displayed.
– For multiple thumbnails, create the variables and fields in a loop. And finally initialize all the variables after the form is created.