SQL row conversion columns (column conversion rows), JavaScript Solutions

Source: Internet
Author: User

SQL does not have row conversion columns:

The ideal result is that the groupName with Objectid 77 is merged into one row.

Finally, let's look at the page effects of js processing.

Some friends may ask different results. I modified the data later. After all, this is the final page with some bugs modified.

Js Code:

Js:

Var ztCallBack = function ztCallBack (json) {if (json. result = "0") {json = null;} else {for (var I = 0; I <json. rows. length-1; I ++) {for (var j = I + 1; j <json. rows. length; j ++) {if (json. rows [I]. objectID = json. rows [j]. objectID) {json. rows [I]. groupName + = "," + json. rows [j]. groupName; json. rows. splice (j, 1) ;}}for (var I = 0; I <json. rows. length; I ++) {if (json. rows [I]. groupName = Null | json. rows [I]. groupName = "") {json. rows [I]. groupName = "ungrouped";} json. rows [I] ["direct"] = Math. random () * 360; json. rows [I] ["uni_status"] = []; json. rows [I] ["uni_alerts"] = [] ;}} var columns = [{display: 'terminal card No. ', name: 'sim', minWidth: 90 }, {display: 'group', name: 'groupname', width: 120, align: 'left'}, {display: 'status', name: 'state', width: 70, align: 'left'}, {display: 'id', n Ame: 'objectid', id: "ObjectID", minWidth: 0, isAllowHide: false}]; var id = $ ("# userGridID"), obj = {id: id, columns: columns, data: json, sortName: 'usermangerid', width: "98%", height: "94%"}; guidObj = liGrid (obj); guidObj. onload = f_hideCity (); if (json! = Null) {// added batch vehicles wimap. addVehicles (json. Rows); wimap. findVehicle (json. Rows [0]. ObjectID, true, true );}}

 

 

Related Article

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.