Home > Web Front-end > Layui Tutorial > Table method rendering in layui

Table method rendering in layui

Release: 2020-04-04 17:26:03
forward
4919 people have browsed it

Table method rendering in layui

When using layui, you need to introduce the entire lib file into the project, and then introduce the layui.css and layui.js files on the page.

When using the built-in modules in layui, use layui.use to quote:

layui.use(['layer' , 'table],function(){
var layer = layui.layer;
var table = layui.table;
})
Copy after login

For the usage of layer, just read the official documentation directly. Here, I only record the ones that I usually use and are hard to find.

1. When rendering using the table method, sometimes the front end needs to add an auto-incrementing serial number, so how to add it?

table.render({
                elem: '#dataTable',
                url:"getDataOrderList",
                // data: data,
                page:{
                    count:'count',
                    limit:20
                },
                cols: [[
                    {type:'numbers',title:'序号',align:'center'}, // 自增序号
                    {field: 'order_no', title: '订单编号'},
                    {field: 'tel', title: '购买账号'},
                    {field: 'total_price', title: '服务金额',color:"red"},
                    {field: 'pay_time', title: '支付时间'},
                    {title: '服务有效期',toolbar:'#detail'},
                    {field: 'buy_by', title: '开通方式'}
                ]]
            });
Copy after login

There is another question, what should I do if there is an operation? Like viewing, editing etc? In the above render method, there is a field called service validity period. There is an attribute in toolbar. Its attribute value is the code in HTML:

<table  class="layui-table" id="dataTable" lay-filter="dataTable"></table>

script type="text/html" id="detail"> //id值关联这toobar的属性值
     <a href="javascript:;" style="color: #468aff" lay-event="detail">查看详情</a>
</script>
Copy after login

For more layui knowledge, please pay attention to layui usage tutorialcolumn.

The above is the detailed content of Table method rendering in layui. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:oschina.net
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template