About table dynamic Add data cell merge array merge

Source: Internet
Author: User

var NEWARR = [
{"Branchid": 1, "Branchname": "City II", "Branchfullname": "City Two Branch", "Issuetypeid": 101, "Issuetypename": "Macro honeycomb tablet weak coverage", "total" : 242, "Withoutdemand": 139, "Withdemand": 103},

{"Branchid": 2, "Branchname": "City II", "Branchfullname": "City Two Branch", "Issuetypeid": 102, "Issuetypename": "Macro honeycomb 2G high upside down", "total" : 146, "Withoutdemand": "Withdemand": 79},

{"Branchid": 3, "Branchname": "City II", "Branchfullname": "City Two Branch", "Issuetypeid": 103, "Issuetypename": "Macro Cellular road black spot", "Total" : 334, "Withoutdemand": 151, "Withdemand": 183},

{"Branchid": 4, "Branchname": "City II", "Branchfullname": "City Two Branch", "Issuetypeid": 104, "Issuetypename": "Macro honeycomb high load cell", "Total" : "Withoutdemand": $, "Withdemand": 0},

{"Branchid": 5, "Branchname": "City II", "Branchfullname": "City Two Branch", "Issuetypeid": "", "Issuetypename": "Macro cellular new District planning", "Total": 0 , "Withoutdemand": 0, "Withdemand": 0},

{"Branchid": 6, "Branchname": "City II", "Branchfullname": "City Two Branch", "Issuetypeid": 106, "Issuetypename": "Macro cellular complaint", "Total": 989 , "Withoutdemand": 892, "Withdemand": 97},

{"Branchid": 7, "Branchname": "City II", "Branchfullname": "City Two Branch", "Issuetypeid": 107, "Issuetypename": "Macro Cellular market demand", "total": 0 , "Withoutdemand": 0, "Withdemand": 0},

{"Branchid": 8, "Branchname": "City II", "Branchfullname": "City Two Branch", "Issuetypeid": 108, "Issuetypename": "Macro cellular protection demand", "total": 0 , "Withoutdemand": 0, "Withdemand": 0}];

var ths = [];
var td1 = [];
var td2 = [];

for (Var i=0;i<newarr.length;i++) {
Ths.push (Newarr[i]. Branchid);
Td1.push (Newarr[i]. Withdemand);
Td2.push (Newarr[i]. Total);
}

c = Ths.concat (TD1,TD2);//Array Merging

Console.log (c)
var k = 0;
var str = ';
str + = "<table border= ' 1 ' bordercolor= ' #000 ' >";
str + = ' <th colspan= ' 4 >1</th> '; str + = ' <th colspan= ' 4 ' >2</th> ';//cell Merge Horizontal merge colspan= "" Vertical merge Rowspan= "" and table header contents
for (var i = 0; i < i++) {//altogether 13 rows
str + = ' <tr> ';
for (var j = 0; J < 8; J + +) {//Altogether 8 columns
var tds = ' <td> ' + c[k] + ' </td> ';

k++;
str + = TDS;
}
str + = ' </tr> ';
}
str + = ' </table> ';
$ (' #divId '). html (str);

About table dynamic Add data cell merge array merge

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.