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);
    	}
}

 

 

 

vxe-table是一款基于Vue的表格组件,它提供了丰富的表格操作功能,包括动态合并单元格动态合并单元格是指在表格渲染之后,根据一定的规则对单元格进行合并处理,以满足特定的展示需求。 vxe-table实现动态合并单元格通常需要编写一些额外的逻辑代码,具体步骤可以概括为以下几点: 1. 自定义合并规则:首先需要定义一个合并规则的函数,这个函数需要返回一个对象,对象中包含合并的行范围信息。 2. 使用合并配置项:在vxe-table组件中,可以通过设置`merge-method`属性来指定自定义的合并规则函数。 3. 触发合并操作:根据业务逻辑,在适当的时候调用vxe-table提供的`$refs`方法获取表格实例,并调用`doLayout`方法触发合并操作。 示例代码可能如下所示: ```javascript // 定义合并规则函数 const mergeRules = (table, row, column, cell) => { // 根据实际需求编写合并逻辑 if (需要合并的条件) { return { rowspan: 合并行数, colspan: 合并数, rowspanAlign: 'top' // 行合并时的对齐方式 } } } // 在vxe-table组件中使用merge-method属性 xeTable = { // ... 其他配置项 mergeMethod: mergeRules, // ... 其他配置项 } ``` 在使用动态合并单元格功能时,需要注意以下几点: 1. 合并规则函数需要根据实际情况编写,通常依赖于表格的数据内容。 2. 合并操作可能会影响到分页、排序和筛选等其他表格操作,需要在使用时进行相应的调整和测试。 3. 合并单元格会改变DOM结构,需要确保合并后的单元格内容能够正确展示。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值