Home >Web Front-end >JS Tutorial >Detailed example of adding operation buttons to each row of data in EasyUI's DataGrid

Detailed example of adding operation buttons to each row of data in EasyUI's DataGrid

小云云
小云云Original
2017-12-30 14:35:467885browse

Easyui's datagrid adds an operation button after each column of data. How to implement this function? The editor below brings you the implementation code of adding operation buttons for each row of data in EasyUI's DataGrid. Friends who need it can refer to it. I hope it can help you.

In fact, it is very simple to add a row of custom columns. When declaring the datagrid in js, add the following code


{field:'operate',title:'操作',align:'center',width:$(this).width()*0.1, 
  formatter:function(value, row, index){ 
    var str = &#39;<a href="#" rel="external nofollow" name="opera" class="easyui-linkbutton" ></a>&#39;; 
    return str; 
}}

This line of code is under the columns attribute Defined, and must add this code


onLoadSuccess:function(data){  
    $("a[name=&#39;opera&#39;]").linkbutton({text:&#39;下订单&#39;,plain:true,iconCls:&#39;icon-add&#39;});  
},

If you don’t add this, the button style will not appear in the operation column, just a hyperlink, use linkbutton or Other buttons can be adapted according to needs

The final effect is as follows

After that, you can do onclick events for the a tag, depending on the situation

Related recommendations:

Detailed explanation of Datagrid in EasyUi control

Detailed explanation of EasyUI's DataGrid binding Json data source method

EasyUI dataGrid inline editing

The above is the detailed content of Detailed example of adding operation buttons to each row of data in EasyUI's DataGrid. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn