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

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

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

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

前台代码:

	<table class="table_solid" border="0" cellspacing="0" id="list">
			<tr>
				<th width="16%">星期</th>
				<th width="16%">会议或活动名称</th>
				<th width="16%">开始时间</th>
				<th width="16%">结束时间</th>
				<th width="16%">主办单位</th>
				<th width="16%">会议地点</th>
			</tr>
			<c:if test="${not empty list}">
				<c:forEach items="${list}" var="item" varStatus="status">
					<tr id="list">
						<td>${item.weeks}</td>
						<td>${item.title}</td>
						<td>${item.beginDate}</td>
						<td>${item.endDate}</td>
						<td>${item.zbdw}</td>
						<td>${item.meetPlace}</td>
					</tr>
			</c:forEach>
			</c:if>
	</table>


下面是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);
                    });


  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值