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

Table method rendering in layui

尚
forward
2020-04-04 17:26:034917browse

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;
})

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: '开通方式'}
                ]]
            });

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>

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!

Statement:
This article is reproduced at:oschina.net. If there is any infringement, please contact admin@php.cn delete