Easyui datagrid custom operation Column

Source: Internet
Author: User

Use the formatter method to add operation links to each row of the Jquery easyui datagrid.

We all know that Jquery's EasyUI datagrid can be added and custom Toolbar,

In this way, select a row and select the corresponding button of the toolbar to operate the data in this row.

However, in actual projects, we may need to add some operation links behind each line, such as "modify", "delete", and "View. For example:

Step 1: Add a column in the datagrid row. The fieid points to the id (fieid: 'id '),

Format the column (formater: formater function) as follows:

<Th data-options = "field: 'id', width: 60, align: 'center', formatter: formatter"> operation </th>

Step 2: The formatter has three parameters:

Value: the value of the field, that is, fidid: 'id '.

RowData: Row data, which is the JSON data of a row.

RowIndex: Row Index, the Index of the current row.

Therefore, a formatting function is required, and only one simple response is required.

<Script type = "text/javascript"> function formattings (val, row, index) {return '<a href = "' + row [" ID "] + '"> modify </a>' ;}</script>

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.