table 实现动态合并单元格

<td DEVICE_NAME=$!map.get("DEVICE_NAME") RISK_NAME=$!map.get("RISK_NAME") RISK_CODE=$!map.get("RISK_CODE") COMPANY_NAME=$!map.get("COMPANY_NAME")>$!map.get("RISK_NAME")</td>
					<td DEVICE_NAME=$!map.get("DEVICE_NAME") RISK_NAME=$!map.get("RISK_NAME") RISK_CODE=$!map.get("RISK_CODE") COMPANY_NAME=$!map.get("COMPANY_NAME")><a href="javascript:viewRelInfo(0,'$!map.get("RISK_ID")')">$!map.get("RISK_CODE")</a></td>
window.onload = function(){ 
    var actionType= jQuery("#actionType").val();
    if( actionType == "detail_risk"){ 
    	rowSpanJs([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],actionType);
    	
    }else if(actionType == "detail_prodplan") {
    	rowSpanJs([0,1,2,3],"detail_prodplan");
    }else{
    	rowSpanJs([0,1,2],"no_detail_risk");
    }
}  

function rowSpanJs(colArr,actionType){
    jQuery.fn.rowspan = function(i) {
	        return this.each(function() {
	            var that;
	            $('tr', this).each(function(row) {
	                $('td:eq(' + i + ')', this).filter(':visible').each(function(col) {
	                       var  this_riskName = $(this).attr('risk_name');
	                       var  that_riskName = $(that).attr('risk_name');
	                       var  this_risk_code = $(this).attr('risk_code');
	                       var  that_risk_code = $(that).attr('risk_code');
	                       var  this_company_name = $(this).attr('company_name');
	                       var  that_company_name = $(that).attr('company_name');
	                       var falg = false;
	                       if( actionType == "detail_risk"   && that != null && !! that_riskName 
	                	        && this_riskName == that_riskName && $(this).attr('risk_level') == $(that).attr('risk_level') 
	                	        && $(this).attr('event_level') == $(that).attr('event_level')  && this_company_name == that_company_name ){
	                       		falg = true;
	                       }else if(actionType == "no_detail_risk"  && that != null  && !! that_riskName   
							     && this_riskName == that_riskName && this_risk_code == that_risk_code
							     && this_company_name == that_company_name){
	                       		falg = true;
	                       }else if(actionType == "detail_prodplan"  && that != null  && !! that_riskName   
							     && this_riskName == that_riskName && this_company_name == that_company_name
							     && $(this).attr('device_name') == $(that).attr('device_name') ){
	                       		falg = true;
	                       }
	                	    if(falg){ 
					    	  rowspan = $(that).attr("rowSpan");
		                        if (rowspan == undefined) {
		                            $(that).attr("rowSpan", 1);
		                            rowspan = $(that).attr("rowSpan");
		                        }
		                        rowspan = Number(rowspan) + 1;
		                        $(that).attr("rowSpan", rowspan);
		                        $(this).hide();
						    }else{
						    	 that = this;
						    }
	                });
	            });
	        });
	      }  
    	for(var colIndex=0;colIndex < colArr.length;colIndex++){
    		 $("#table-list").rowspan(colIndex,actionType);
    	}
}


猜你喜欢

转载自blog.csdn.net/qq_31806719/article/details/80927131
今日推荐