如果数据相同,则使用html表跨度 [英] html table span if the data is same

查看:109
本文介绍了如果数据相同,则使用html表跨度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在列中有一个包含重复数据的html表格,如下所示:

我想动态合并HTML表格行单元格,如果数据与下表相同





我可以通过给单元格的数量来实现这个功能,但是我怎样才能动态地执行这个操作?

解决方案

<哇,谢谢你的有趣的任务。我想出了这个解决方案 http://jsfiddle.net/PhWGF/4/ 。不是最干净的代码,但我会为你留下这部分。



你可以把你的表看作一个普通的 2d数组注意,您需要设置所有roswpan在删除重复之前。


I have a html table with duplicate data in the column as shown below

I want to dynamically merge the html table row cell if the data is same like below table

I am able to do this with giving the value number of cells to span but how can I do this dynamically

解决方案

Wow, thanks for the interesting task. I came up with this solution http://jsfiddle.net/PhWGF/4/. Not the cleanest code but I will leave this part for you.

You can think about your table as a regular 2d array so it all comes down to the classical nested loops. We search for a duplicate for each cell in each row of the same column, store first and last occurrence to determine the length of span later.

Note, you need to set all "roswpan" before deleting duplicates.

这篇关于如果数据相同,则使用html表跨度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆