Jqgrid's fomatter is used to convert the image URL address to the front-end picture display

Source: Internet
Author: User
Tags jqgrid

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

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.