I recently made the change to develop client side code in SmartGWT as opposed to JavaScript, and am having a little ;-) trouble with displaying images within a ListGrid.
I have seen a couple of other related threads such as
and
so I can see I'm not the first to encounter difficulties.
The images I am displaying are actually stored in the database, but they are then persisted to the local file system on the server for retrieval by client side code.
I succeeded in using the addEmbeddedComponent route but I don't really want to continue using this option for some behavioural reasons (the ListGrid doesn't get the start editing notification when the user double clicks on the image because the Img instance receives this notification.)
I was really happy with the way getValueIcon works because I had a function looking like this:
There is no getValueIcon method on ListGrid although there is a method ListGridField.setValueIcons( Map<String, String> ), but I didn't succeed in using this because the key value in my case is binary data.
I have tried ListGridField.setShowFileInline( true ) in conjunction with a datasource definition as follows but didn't get any luck.
Anyway, I'm really happy to be developing all aspects of the solution in Java within Eclipse because I can debug my server- and client-side code without switching to any other environment and of course I can see all the methods and hierarchy tree for components immediately. Fantastic!
Do you have any suggestions please as to which route I should take?
I have seen a couple of other related threads such as
Code:
http://forums.smartclient.com/showthread.php?t=9060&highlight=showfileinline
Code:
http://forums.smartclient.com/showthread.php?t=9739&highlight=addEmbeddedComponent
The images I am displaying are actually stored in the database, but they are then persisted to the local file system on the server for retrieval by client side code.
I succeeded in using the addEmbeddedComponent route but I don't really want to continue using this option for some behavioural reasons (the ListGrid doesn't get the start editing notification when the user double clicks on the image because the Img instance receives this notification.)
I was really happy with the way getValueIcon works because I had a function looking like this:
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; }
I have tried ListGridField.setShowFileInline( true ) in conjunction with a datasource definition as follows but didn't get any luck.
Code:
<DataSource ID="images1276259338037ds" tableName="images" title="images" > <fields> <field name="id" type="sequence" hidden="false" primaryKey="true" canEdit="false"/> <field name="description" type="text" hidden="false" primaryKey="false" length = "100" /> <field name="picture" type="imageFile" hidden="false" primaryKey="false" /> </fields> </DataSource>
Do you have any suggestions please as to which route I should take?
Comment