Skip to content

[Bug] 当进行删除行操作并进行renderWithRecreateCells时,switch单元格表现错误,已删除的那一行的switch状态保留到了下一行 #4436

@robertyclin

Description

@robertyclin

Version

1.19.7

Link to Minimal Reproduction

https://visactor.io/vtable/demo/cell-type/switch

Steps to Reproduce

const records = [
{ productName: 'Apple', price: 20, switch: true },
{ productName: 'Banana', price: 18, switch: false },
{ productName: 'Cherry', price: 16, switch: true },
{ productName: 'Date', price: 14, switch: false },
{ productName: 'Elderberry', price: 12, switch: true },
{ productName: 'Fig', price: 10, switch: false },
{ productName: 'Grape', price: 8, switch: true }
];

const columns = [
{
field: 'productName',
title: 'name',
width: 120
},
{
field: 'price',
title: 'price',
width: 120
},
{
field: 'switch0',
title: 'switch',
width: 'auto',
cellType: 'switch',
checkedText: 'on',
uncheckedText: 'off',
style: {
color: '#FFF'
}
},
{
field: 'switch1',
title: 'disabled switch',
width: 'auto',
cellType: 'switch',
checkedText: 'on',
uncheckedText: 'off',
style: {
color: '#FFF'
},
disable: true
},
{
field: 'switch',
title: 'custom switch',
width: 'auto',
cellType: 'switch',
style: {
color: '#FFF'
},
checkedText: args => {
return 'on' + args.row;
},
uncheckedText: args => {
return 'off' + args.row;
}
}
];
const option = {
records,
columns
};
const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
window['tableInstance'] = tableInstance;

setTimeout(() => {
// 进行删除操作,并重新渲染表格
tableInstance.deleteRecords([0]);
tableInstance.renderWithRecreateCells();
}, 6000)

Current Behavior

删除之前第一行的switch是打开的,第二行的switch是关闭的;删除第一行之后,第一行的switch还是打开的

Expected Behavior

删除之前第一行的switch是打开的,第二行的switch是关闭的;删除第一行之后,第一行的switch应该是关闭的

Environment

- OS: macOS Monterey
- Browser: Chrome 96.0.4664.55
- Framework: Vue@3

Any additional comments?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions