Easyui Learning: DataGrid display picture and preview the implementation method __datagrid display picture

Source: Internet
Author: User
Displays the picture in the Easydatagrid list, and realizes clicks the preview function, may use the following method to implement:


Below I use the Picture field format as: Upload/file/aa.png,upload/file,bb.png to simply explain



This is the line shown in the DataGrid list.

<th data-options= "field: ' Goods_img ', width:90,align: ' Center ', formatter:imgformatter ' > Product picture </th>

Show the JS function of a picture

  //Picture Add path       function Imgformatter (value,row,index) {            if ('!= value && null!= value) {        & nbsp var STRs = new Array ();
Define an array             if (value.substr (value.length-1,1) = = ",") { 
            value=value.substr (0,value.length-1)          }                STRs = Value.split (","); Character segmentation           var rvalue = "";                      for (i=0;i<strs.length i++) {     & nbsp;          rvalue + = " ' + strs[i] + ' title= ' Click to view the picture '/> ';              }             return  rvalue;                  }          }  //Here you need to define a div   To create a Easyui window display picture       function Dimgloadwin (img) {           var simg =  "http://www.**.com/" + img;           $ (' #dahuikuimg '). Dialog ({               title: ' Preview ',                width:800,               height:800,               resizable: True,               Closed:false,                Cache:false,                modal:true          });           $ ("#simg"). attr ("src", simg);
      }     

Record a line of code before the end of the body:

<div id= ' dahuikuimg ' ></div>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.