动态列合并table

效果演示
动态列合并table_第1张图片
核心js
combineCell:function(list) {
        for (var field in list[0]) {
            var k = 0
            while (k < list.length) {
                list[k][field + 'Span'] = 1
                list[k][field + 'Dis'] = false
                for (var i = k + 1; i <= list.length - 1; i++) {
                    if (list[k][field] == list[i][field] && list[k][field] != '') {
                        list[k][field + 'Span']++
                        list[k][field + 'Dis'] = false
                        list[i][field + 'Span'] = 1
                        list[i][field + 'Dis'] = true
                    } else {
                        break
                    }
                }
                k = i
            }
        }
        return list
    }
html

你可能感兴趣的:(动态列合并table)