//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;
}
}
});
}
});
} });
};
解决jqgrid中rowspan
最新推荐文章于 2024-06-20 13:28:39 发布