I'm adding image to DataGrid cell with formatter. The problem is that the image gets partially cut out (limited to row default height). If I add static width and height attribute, problem is fixed, but in this case image sizes are dynamic. Also if I only add text, row height is grown correctly.
<div dojotype="dojo.data.ItemFileReadStore" id="store" jsid="JsonStore" url="/data"></div>
<table dojotype="dojox.grid.DataGrid" id="gridNode" jsid="grid" query="{ id: '*' }" store="JsonStore" escapeHTMLInData="true" width="60em">
<thead>
<tr>
<th field="id" formatter="imageButton" width="auto" height="auto">Image</th>
</tr>
</thead>
</table>
<script type="text/javascript">
//<![CDATA[
// Formatter
function imageButton(value)
{
var url = 'original/id/' + value;
var imgUrl = 'dynamic/id/' + value;
var img = '<img src="' + imgUrl + '" alt="" />';
var imgLink = '<a href="' + url + '" />' + img + '</a>';
var link = '<a href="' + url + '" alt="" />Open original image</a>';
return imgLink + '<br />' + link;
}
dojo.addOnLoad(function() {
var grid = dijit.byId('gridNode');
// Tried also with this kind of approach
// but onFetchComplete is too soon, formatters are still doing work
dojo.connect(grid, "_onFetchComplete", function(items) {
// ??grid.howToRefresh()??;
});
});
//]]>
</script>