Hi,
If you have ImageResource, you can use
com.google.gwt.cell.client.ImageResourceCell .
If you have only urls, you can create your own ImageCell like
com.google.gwt.cell.client.ImageCell and change html template used :
public class MyImageCell extends AbstractCell<String> {
interface Template extends SafeHtmlTemplates {
@Template("<img src=\"{0}\" style=\"width:20px;height:20px;\"/>") //
20*20 size
SafeHtml img(String url);
}
private static Template template;
/**
* Construct a new MyImageCell.
*/
public MyImageCell() {
if (template == null) {
template = GWT.create(Template.class);
}
}
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
if (value != null) {
// The template will sanitize the URI.
sb.append(template.img(value));
}
}
}
Alexandre.
2011/3/20 Hong <[email protected]>
> Hi, everyone
>
> I tried to put some images in gwt cell table where I used image cells
> to do this. But those images turned out pretty large in the webpage. I
> tried to use "aCellTable.setColumnWidth(column, width)", but it didn't
> help. I know if only to display a single image, I can say "String url
> = anImageResource.getUrl(); Image aImage = new Image(url);
> aImage.setPixelSize(x,y);" things like that. But how can I scale an
> image in a image cell / cell table?
>
> Some of my codes:
>
> CellTable<VehicleInfo> vehicleCellTable = new
> CellTable<VehicleInfo>(1);
>
> .....
>
> Column<VehicleInfo,String> imageColumn = new
> Column<VehicleInfo,String>(new ImageCell())
> {
>
> @Override
> public String getValue(VehicleInfo object) {
>
> return object.imageUrl;
> }
>
> };
>
> vehicleCellTable.addColumn(imageColumn,"Image");
>
> vehicleCellTable.setColumnWidth(imageColumn, "3em"); //doesn't help
>
> .....
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.