本文主要是介绍基于MVC+EasyUI的返回Json数据处理Table表合并单元格Jquery写法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
function GetList() {$.ajax({type: 'post',dataType: 'json',url: "kbcxxx_xskbcx",data: { 'lx': 'ss', 'code': term },cache: false,success: function (data) {$('#kbxx tbody').empty();$.each(data.rows, function (i, o) {//处理循环的数据,根据自己的业务情况操作。。。。});var cells = [];for (var i = 0; i <= 7; i++) {cells.push("z" + i);//数据库查询结果,转换为JSON数据的key的名称,不是指key对应的值数据}mergeCells_table('kbxx', data, cells);},error: function (e) {}});}<table id="kbxx">
</table>
//dg:table表的id,data:返回JSON数据,cellnames:数组,指json数据的key名称,不是指key对应的值数据
function mergeCells_table(dg, data, cellnames) {var table = document.getElementById(dg);for (var i = 0; i < cellnames.length; i++) {var cellname = cellnames[i];var merges = [];for (var r = 0; r < data.rows.length; r++) {var row = data.rows[r];var mergeinfo = new Object();var nr = row[cellname];var rowspan = 1;for (var r1 = r + 1; r1 < data.rows.length; r1++) {var row1 = data.rows[r1];var nr1 = row1[cellname];if (nr1 && nr1 == nr && nr1 != "") {mergeinfo.index = r;rowspan++;mergeinfo.rowspan = rowspan;table.rows[r + 1].cells[i].rowSpan = rowspan;table.rows[r1 + 1].cells[i].style.display = "none";}else {if (rowspan > 1) {merges.push(mergeinfo);r = r1 - 1;}break;}if (r1 == data.rows.length - 1) {if (rowspan > 1) {merges.push(mergeinfo);r = r1 - 1;}}}}}
}
这篇关于基于MVC+EasyUI的返回Json数据处理Table表合并单元格Jquery写法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!