Thanks to visit codestin.com
Credit goes to github.com

Skip to content

多层表头 表头渲染正确但数据列 没有按正确顺序渲染 #27

@tianchengcheng-bql

Description

@tianchengcheng-bql

多层表头 表头渲染正确但数据列 没有按正确顺序渲染

修复方法:hiprint.bundle.js 源码1740行代码,TableExcelHelper.getOrderdColumns方法修复

TableExcelHelper.getOrderdColumns = function (t) {
            	var maxRow = t.totalLayer;
                var ret = [];
                // 查找下层节点数据
                var rowColStartMap = {};
                var findLeafCol = function(nextRow, colspan){
                    var matchCols = [];
                    var start = rowColStartMap[nextRow]?rowColStartMap[nextRow]+1:0;
                    for(var i=start;i<t[nextRow].length;i++){
                        if(i - start >= colspan){
                            break;
                        }
                        if(t[nextRow][i].colspan > 1){
                            var dRet = findLeafCol(nextRow+1, t[nextRow][i].colspan);
                            dRet.forEach(function(dt){
                                matchCols.push(dt);
                            });
                        }else{
                            matchCols.push(t[nextRow][i]);
                        }
                        rowColStartMap[nextRow] = i;
                    }
                    return matchCols;
                }
                // 从顶部迭代
                var startRow = 0;
                t[startRow].forEach(function (t) {
                    if(maxRow == t.rowspan || 1 == t.colspan){
                        // 行到底层或者只占1列的数据
                        ret.push(t);
                    }else{
                        // 从next row取数据
                        var matchCols = findLeafCol(startRow+1, t.colspan);
                        matchCols.forEach(function(mt){
                            ret.push(mt);
                        });
                    }
                });
                return ret;
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions