Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 使用extjs在网格列中显示BLOB图像_Image_Extjs_Grid_Extjs4_Blob - Fatal编程技术网

Image 使用extjs在网格列中显示BLOB图像

Image 使用extjs在网格列中显示BLOB图像,image,extjs,grid,extjs4,blob,Image,Extjs,Grid,Extjs4,Blob,我正在开发一个基于ExtJS的应用程序,我有一个表单可以上传BLOB格式的图像。嗯,我在数据库中有这个图像,但现在我想在网格列中显示它,但我不知道怎么做。一些代码: 型号: Ext.define('pssp.model.icon.IconItem', { extend : 'Ext.data.Model', fields : [{ name : 'id', type : 'int' }, { name : 'fileName', type : 'str

我正在开发一个基于ExtJS的应用程序,我有一个表单可以上传BLOB格式的图像。嗯,我在数据库中有这个图像,但现在我想在网格列中显示它,但我不知道怎么做。一些代码:

型号:

Ext.define('pssp.model.icon.IconItem', {
  extend : 'Ext.data.Model',
  fields : [{
    name : 'id',
    type : 'int'
  }, {
    name : 'fileName',
    type : 'string'
  }, {
    name : 'iconBmp', => BLOB
    type : 'auto'
  }, {
    name : 'description',
    type : 'string'
  }]
});
视图:

“iconBmp”显示以下内容:

R0lGODlhFgAWALMAAB1ChF9vjzljwliE34Kl8b/I16PD+8ZMZPDW7GaAAAAAAAAAAAAAAAAAAAAAAAAAAAAFGAWAAIKAPCBxBgBgQgSkHchchhabHpoxiecheihavjixQbHwGqCaAsynch40Qdly1HdPyPyPpSqlharyKusz0GcqUcqUcqUcBjM6VCM0qrJgQjGqJjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjKjK=

如何将此图像(“iconBmp”)显示为真实图像


提前谢谢

我回答自己,我只需要写一行,因为数据已经是base64格式,这是:

xtype: 'gridcolumn',
dataIndex : 'iconBmp',
id:'iconBmp',
name: 'iconBmp',
text : this.i18nColIconBmp,
flex : 1,
renderer : function(value) {
  return '<img src="data:image/gif;base64,' + value +  '" />';
}
xtype:'gridcolumn',
数据索引:“iconBmp”,
id:'iconBmp',
名称:'iconBmp',
文本:this.i18nColIconBmp,
弹性:1,
渲染器:函数(值){
返回“”;
}

我写的是
gif
,因为我的图像是一幅gif图像,在这一行中,我必须检查图像的格式。

看起来您的图像以有效的Base64返回,这很好。这可能不是最好的Ext JS方式。。。不确定是否真的有。。。但我认为您可以将HTML和Ext JS结合使用,可能如下所示:

, {
  xtype: 'gridcolumn', => This only show a String of bytes
  dataIndex : 'iconBmp',
  id:'iconBmp',
  name: 'iconBmp',
  text : this.i18nColIconBmp,
  flex : 1,
  tpl:'<img src="data:image/gif;base64, {iconBmp}" />'
}
{
xtype:'gridcolumn',=>这只显示一串字节
数据索引:“iconBmp”,
id:'iconBmp',
名称:'iconBmp',
文本:this.i18nColIconBmp,
弹性:1,
第三方物流:''
}

非常感谢您的快速回复,但我找到了方法,10分钟前我已经发布了:)是的,当我发布时它还不存在。无论哪种方式,都有两种解决方案。。。所以它至少对你我来说是一个很好的参考:)
, {
  xtype: 'gridcolumn', => This only show a String of bytes
  dataIndex : 'iconBmp',
  id:'iconBmp',
  name: 'iconBmp',
  text : this.i18nColIconBmp,
  flex : 1,
  tpl:'<img src="data:image/gif;base64, {iconBmp}" />'
}