前台接收后台传过来的list进行遍历,然后根据表格用合并rowspan列

将数据以表格的信息进行展示,但是两行的开头要进行合并,可以用好多方法,下面是其中的一种:

后台代码使用的是spring mvc(我进行了简化):

	ModelAndView mv = new ModelAndView("页面路径");
	List list = this.meetFindManager.findMeetInfoList();
	mv.addObject("list", list);
	return mv;

前台代码:

	
				
					
星期 会议或活动名称 开始时间 结束时间 主办单位 会议地点
${item.weeks} ${item.title} ${item.beginDate} ${item.endDate} ${item.zbdw} ${item.meetPlace}


下面是js代码:

	jQuery.fn.rowspan = function(colIdx) { //封装的一个JQuery小插件
        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;
        }
        });
        });
        });
        }
        //调用表单的id
		$("#list").rowspan(0);
		$(function() {
        	$("#list").rowspan(0); //传入的参数是对应的列数从0开始,哪一列有相同的内容就输入对应的列数值
        	$("#list").rowspan(1);
                    });
前台接收后台传过来的list进行遍历,然后根据表格用合并rowspan列_第1张图片

你可能感兴趣的:(前台接收后台传过来的list进行遍历,然后根据表格用合并rowspan列)