使用JQuery删除Table中的合并行

    SAP BPS  Web Interface中的Layout控件,不知道如何去改变同列值相同合并的功能,因为要用以前使用的JS来做Save To Excel功能,而我又恰恰不需要开始的两列,所以特定写了一段代码进行列删除。 列删除唯一要考虑的是对应存在行合并的列,需要跳过一些行。

  $("#LAYOUT_DOWNLOAD-table").find("tr").each(function(i){
   if(i == 0){ // 第一行是标题,直接删除就好了
      $(this).find("td").eq(0).remove();
       $(this).find("td").eq(0).remove(); 
    }else if(i == 1 ){ //从第二行开始可能存在行合并的情况
    c1_rows= $(this).find("td").eq(0).attr("rowspan");
    c2_rows= $(this).find("td").eq(1).attr("rowspan");
    $(this).find("td").eq(0).remove();
      $(this).find("td").eq(0).remove();
      c1_rows = c1_rows - 1;
      c2_rows = c2_rows - 1;
    }else if( i > 1){
     if( c1_rows > 0){ //还有合并行,所以要在考虑
      c1_rows = c1_rows - 1;
      if(c2_rows > 0){
       //什么也不用做
       c2_rows = c2_rows - 1;
      }else{
       c2_rows= $(this).find("td").eq(0).attr("rowspan");
       $(this).find("td").eq(0).remove();
       c2_rows = c2_rows - 1;
       }    
     }else{ //重新开始获取合并行数
      c1_rows= $(this).find("td").eq(0).attr("rowspan");
      c2_rows= $(this).find("td").eq(1).attr("rowspan");
      $(this).find("td").eq(1).remove();
        $(this).find("td").eq(1).remove();
        c1_rows = c1_rows - 1;
        c2_rows = c2_rows - 1;      
      
     }
    }

  });

又老了半岁,不过还好,理清楚了。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/554557/viewspace-697914/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/554557/viewspace-697914/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值