日期:2014-05-16 浏览次数:20408 次
<style>
table{ border-collapse:collapse; }
td{border:1px solid #000; }
</style>
<table border=1 id="t1" >
<tr>
<td>id</td><td>prop</td><td>belong</td><td>com</td>
</tr>
</table>
<script>
var ds=[{id:'01',prop:'0',belong:'Scott',com:'Company A'},
{id:'01',prop:'0',belong:'Scott',com:'Company A'},
{id:'02',prop:'0',belong:'Smith',com:'Co.B'},
{id:'01',prop:'1',belong:'Anderson',com:'Company A'},
{id:'01',prop:'1',belong:'Scott',com:'Company A'}];
ds.sort(function(a,b){
return a.id+a.prop > b.id+b.prop ?1:-1
});
t1=document.getElementById('t1');
var cls='id prop belong com'.split(' ');
for(var i=0;i<ds.length;i++){
var r= t1.insertRow(-1);
for(k in ds[i]) r.insertCell(-1).innerHTML=ds[i][k];
}
function mergeCell(tb,i){
var rs=tb.rows,ac,acv;
if(!rs.length) return;
for(var r=0;r<rs.length;r++){
var cs=rs[r].cells, c=cs[i];
if( !ac
------解决方案--------------------
(c.innerHTML!=ac.innerHTML ) ){
ac=c;