layui行转列的偷懒写法
var tempCols = [];//转换后的列头
var tempData = [];
var entcount = {};//转换后的第一行, 也就是原来的第一列
var stockcount = {}//转换后的第2行, 也就是原来的第2列
var wfsy2 = {};
var ypgl2 = {};
var dzje2 = {};
entcount.ORG_NAME = '法人数';
stockcount.ORG_NAME = '控参股法人数';
for (var i = 0; i < data.length; i++) {
var row = data[i];
var filedName = 'col' + i
tempCols.push({ field: filedName, title: row.org_name, width: "6%", align: 'center' });
entcount[filedName] = row.entcount;
stockcount[filedName] = row.stockcount;
wfsy2[filedName] = row.two_ourrevenue;
ypgl2[filedName] = row.two_involved_devidend;
}
...中间省略
rowCols = [tempCols];
注意最后的cols得多加个[]
完活儿~~~