jquery 合並單元格,rowspan


(function ($) {
    $.fn.extend({
        //表格合並單元格,colIdx要合並的列序號,從0開始  
        "rowspan": function (colIdx) {
            return this.each(function () {
                var that;
                $('tr', this).each(function (row) {
                    $('td:eq(' + colIdx + ')', this).filter(':visible').each(function (col) {
                        if (that != null && $(this).html() == $(that).html()) {
                            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;
                        }
                    });
                });
            });
        }
    });
})(jQuery);
調用
$("#tableRelate").rowspan(0); //第一列合並 $("#tableRelate").rowspan(1);//第二列合並
如果是單個數據,合並行
<#if rhQyList['xxgyDwdb']??&&rhQyList['xxgyDwdb']?size gt 0>
                    <#list rhQyList['xxgyDwdb'] as dwdb>
                    <tr>
                        <td>${dwdb.dbTitle}</td>
                        <td>${dwdb.strokeCount}</td>
                        <td>${dwdb.suretyAmount}</td>
                        <td>${dwdb.normal}</td>
                        <td>${dwdb.concern}</td>
                        <td>${dwdb.renege}</td>
                        <#if dwdb_index == 0>
                            <td rowspan="${rhQyList['xxgyDwdb']?size}">${rhQyList['totalBalance']}</td>
                        </#if>
                    </tr>
                    </#list>
                </#if>

 

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM