解决jqgrid中rowspan

本文将介绍如何利用jqGrid插件实现表格中指定行的合并操作,包括插件使用方法、代码示例及注意事项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


//jqGrid-ttable-rowspan
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*用法
* $("#tableId").jqGridTableRowSpan("13,14,15");//要合并的列序号,散列形式
* 仅仅只适用于jqGrid
*
*
* */
jQuery.fn.jqGridTableRowSpan = function(colIndexs) {
return this.each(function() {
var indexs = eval("([" + colIndexs + "])");
for (var i = 0; i < indexs.length; i++) {
var colIdx = indexs[i];
var that=new Array();
var firstrowspan=0;
$('tbody tr', this).each(function(row) {
for(var k=0;k<colIdx.length;k++){
$('td:eq(' + colIdx[k] + ')', this).filter(':visible').each(
function(col) {
if (that[k] != null && $(this).html() == $(that[k]).html()) {
rowspan = $(that[k]).attr("rowSpan");
if (rowspan == undefined) {
$(that[k]).attr("rowSpan", 1);
rowspan = $(that[k]).attr("rowSpan");
}
rowspan = Number(rowspan) + 1;
if(k==0){
$(that[k]).attr("rowSpan", rowspan);
$(this).hide();
firstrowspan=rowspan;
}
if(k!=0&&rowspan<=firstrowspan){
$(that[k]).attr("rowSpan", rowspan);
$(this).hide(); }
} else {
if(k==0){
//if it is the first of the group then set others null ,
that=new Array();
that[0]=this;
}else{
that[k] = this;
}
}
});
}
});
} });
};
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值