使用layui,从后台动态拿到数据,如何点击第一行获取到第一行 的编号进行跳转
点击第二行获取第二行的数据进行跳转
layui.use(['form', 'table'], function () {
var $ = layui.jquery,
form = layui.form,
table = layui.table;//获取当前页面所有的table
var columns = [
{field: 'zdid', title: '工单编号', style:'width:10%',},
{field:'zd_state',title:'使用归属组', tyle:'width:10%', templet:function (c) {
return c.zd_state.access_network}, },
];
//渲染表格
table.render({
elem: '#demo',//指定table的id
url: '/zd/ceshicha',
toolbar: '#toolbarDemo',
done:function(res, curr ,count){
$('th').css(({ 'text-align':'center','background-color': '#bdccea', 'color': 'black', 'font-weight': '500' }))
$('layui-table-total.layui-table tbody tr').css({ 'color': 'red' });
$('.layui-table-total.layui-table tbody tr').css({ 'background-color': '#ffffb4' });
var that = this.elem.next(); res.data.forEach(function (item, index) {
//console.log(item.empName);item表示每列显示的数据
if (index % 2 == 0) {
var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']")
.css(({'border-top':'1px solid black','border-bottom':'dashed','border-left':'1px','text-align':'center'}));
} else {
var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']")
.css(({'border-top':'1px solid red','border-bottom':'dashed','text-align':'center'}));
}
})
},
defaultToolbar: ['filter', 'exports', 'print', {
title: '提示',
layEvent: 'LAYTABLE_TIPS',
icon: 'layui-icon-tips'
}],
method: "post",
cols: [columns],
limits: [10, 15, 20, 25, 50, 100],
limit: 15,
page: true,
skin: 'line'
});