Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] customMergeCell合并后内容显示不全 #1543

Closed
yuzhanyin opened this issue Apr 18, 2024 · 3 comments · Fixed by #1563
Closed

[Bug] customMergeCell合并后内容显示不全 #1543

yuzhanyin opened this issue Apr 18, 2024 · 3 comments · Fixed by #1563
Assignees
Labels
bug Something isn't working

Comments

@yuzhanyin
Copy link

Version

0.23.3

Link to Minimal Reproduction

如下

Steps to Reproduce

`let tableInstance;

const generatePersons = count => {
return Array.from(new Array(count)).map((_, i) => ({
id: i + 1,
email1: ${i + 1}@xxx.com,
name: name${i + 1},
date1: '2022-9-1日',
tel: '000-0000-0000',
sex: i % 2 === 0 ? 'boy' : 'girl',
work: i % 2 === 0 ? 'back-end engineer' : 'front-end engineer',
city: 'beijing'
}));
};
const records = generatePersons(10);

const columns = [
{
field: 'id',
title: 'ID ff',
width: '1%',
minWidth: 200,
sort: true
},
{
field: 'email1',
title: 'email',
width: 200,
sort: true
},
{
title: 'full name',
columns: [
{
field: 'name',
title: 'First Name',
width: 200
},
{
field: 'name',
title: 'Last Name',
width: 200
}
]
},
{
field: 'date1',
title: 'birthday',
width: 200
},
{
field: 'sex',
title: 'sex',
width: 100
},
{
field: 'tel',
title: 'telephone',
width: 150
},
{
field: 'work',
title: 'job',
width: 200
},
{
field: 'city',
title: 'city',
width: 150
}
];

const option = {
records,
columns,
widthMode:'standard',
bottomFrozenRowCount:1,
customMergeCell: (col, row, table) => {
if (col ==0 && row % 2 == 0 && row > 3) {
return {
text: '总结栏:此数据为一份人员基本信息',
range: {
start: {
col: 0,
row: row - 1
},
end: {
col: 0,
row: row
}
},
style:{
borderLineWidth:[6,1,1,1],
borderColor:['gray']
}
};
}
}
};
tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID),option);
window['tableInstance'] = tableInstance;`
bug

Current Behavior

合并后内容显示错误

Expected Behavior

期望合并后内容正常显示

Environment

- OS:win10
- Browser:chrome 123.0.6312.123
- Framework:

Any additional comments?

No response

@yuzhanyin yuzhanyin added the bug Something isn't working label Apr 18, 2024
@yuzhanyin
Copy link
Author

还有customMergeCell: (col, row, table) => {
//console.log(table.getCellValue(col,row)) // 会报错,
bug2
// console.log(table.getCellRawValue(col,row)) 这样又是正常打印出内容的
}
}

@Rui-Sun
Copy link
Contributor

Rui-Sun commented Apr 22, 2024

这里的合并规则写的有问题,规则需要应用到所有单元格

    customMergeCell: (col, row, table) => {
      if (col == 0 && row > 2) {
        if (row % 2 == 0) {
          return {
            text: '总结栏:此数据为一份人员基本信息',
            range: {
              start: {
                col: 0,
                row: row - 1
              },
              end: {
                col: 0,
                row: row
              }
            },
            style: {
              borderLineWidth: [6, 1, 1, 1],
              borderColor: ['gray']
            }
          };
        } else {
          return {
            text: '总结栏:此数据为一份人员基本信息',
            range: {
              start: {
                col: 0,
                row: row
              },
              end: {
                col: 0,
                row: row + 1
              }
            },
            style: {
              borderLineWidth: [6, 1, 1, 1],
              borderColor: ['gray']
            }
          };
        }
      }
    }

image

@Rui-Sun
Copy link
Contributor

Rui-Sun commented Apr 22, 2024

第二个问题,在getCellValue中会判断是否使用的自定义合并,会引起循环调用,getCellRawValue是获取原始数据,不会判断合并,所有不会引起循环调用;后续再getCellValue中加一个skipCustomMerge的参数,提供给合并函数里调用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants