easyUI 合并单元格

在页面中引用  deyi-util.js 。

deyi-util.js :

deyisys.util = {
    tableMerges : function (id, fieldArr) {
		for ( var i = 0; i < fieldArr.length; i++) {
			deyisys.util.tableMerge(id, fieldArr[i]);
		}
	},
    tableMerge : function (id, field) {
		var tabId = '#' + id;
		var rows = $(tabId).datagrid('getRows');
		var len = rows.length;
		var rowStr = "";
		var merges = [];
		var j = 0;
		var x = 0;
		for ( var i = 0; i < rows.length; i++) {
			var row = rows[i];
			if (i == 0) {
				rowStr = row[field];
				var merObj = {};
				merObj.index = 0;
				merges[j] = merObj;
			}
			if (rowStr != row[field]) {
				rowStr = row[field];
				merges[j].rowspan = x;
				x = 1;
				j++;
				var merObj = {};
				merObj.index = i;
				merges[j] = merObj;
			} else {
				x++;
			}
			if (i == (rows.length - 1)) {
				merges[j].rowspan = x;
			}
		}
		for ( var i = 0; i < merges.length; i++) {
			$(tabId).datagrid('mergeCells', {
				index : merges[i].index,
				field : field,
				rowspan : merges[i].rowspan
			});
		}
	},
}

jsp 页面:

onLoadSuccess:function(data){
      	/**页面合并行用*/
        deyisys.util.tableMerges('diseaseGeneList',['diseaseName','subjectName','omim']);
      },

diseaseGeneList:页面table 的Id,['diseaseName','subjectName','omim'] 是要根据哪些列进行合并

你可能感兴趣的:(easyui,java,jquery,编程技术)