Background: Based on SPRINGMVC, the image URL address stored in the MySQL database is read out, then converted to a JSON file, using Jqgrid to display the JSON data, especially the URL of the picture to read the address and then converted into a picture display;
Jqgrid Official documents Chinese translation address: Http://blog.mn886.net/jqGrid/
Jqgrid Official Document: Http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter
Parameters in document-Methods-Events-Colmodel parameters in the document a formatter parameter is found in the submenu, followed by an example, as shown in:
There are three parameters in the function parameter list: Cellvalue, Options, Rowobject
The official explanation is:
Cellvalue: Refers to a value that needs to be formatted, more precisely the value of the current cell (cell) that needs to be formatted
Options: Is an object that contains the following elements
{ROWID:RID,COLMODEL:CM}
ROWID: The ID number of the line
Colmodel: Is the object that gets the properties of the column from the Jqgrid colmodel data
Simply put, it is the options setting of the current cell
Rowobject: Row data presented in a format determined by data type (xml/xmlstring/json/jsonstring) selection
There are blogs that say: Rowobject is the value of the current cell row, such as {id=1, name= "name1", price=123.1, ...} , which means that the data for the current row is represented
Since it is necessary to format the current cell, that is, the code for Cellvalue operation is as follows:
1 function ImageFormat (cellvalue, Options, Rowobject) {234 return ' ; 5 6 7 }
1 {name: ' logo ', index: ' logo ', align: ' center ', sortable:false, editable: true, width:30,Formatter:imageformat},
You can display a picture of the URL address in the cell
Jqgrid still need to learn further!!!
Jqgrid's fomatter is used to convert the image URL address to the front-end picture display