先定义一个会话框里面隐藏一个div标签
<div id="dlgdiv" class="easyui-dialog"
style="width: 650px; height: 550px; padding: 10px 20px" closed="true"
buttons="#dlgdiv-buttons">
<div id="divlarge"></div>
</div>
在图片字段中加一个onclick事件,以this.src方式传入图片地址
{
field: 'pic',
title: 'pic',
align: 'center',
width: '15%',
formatter: function (value, row, index) {
if (value != null) {
return "<img onclick='myfunciton(this.src)' name='smallImg' src='" + value + "' alt='没有图片' width='120px' height='120px' />"
}
return "<div style='height: 120px'><h2 align='center' style='padding-top: 30px' />NO IMG</h2><div>"
}
最后onclick事件中指向的myfunction方法将对话框即里面的图片展示出来
function myfunciton(e) {
var large='<img width="596px" height="453px" src=' +e+ '></img>';
$("#divlarge").html(large).animate({
height:'30%',
width:'30%'
},1);
$("#dlgdiv").dialog("open").dialog("setTitle", "图片展示");
}