We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
自定义单元格中,我想加一些单元格自己的数据,所以就加了几个属性,但是属性的修改看起来没有生效,在渲染完成后,属性会恢复为初始值
import { PivotSheet, DataCell, S2DataConfig, S2Options } from '@antv/s2'; class CustomDataCell extends DataCell { test = 1; // 自定义属性 drawBackgroundShape() { super.drawBackgroundShape(); this.test = 2; //在这里修改属性 console.log('before test', this.test); setTimeout(() => { console.log('after test', this.test); //之后访问又恢复成了1 }) } } fetch( 'https://gw.alipayobjects.com/os/bmw-prod/cd9814d0-6dfa-42a6-8455-5a6bd0ff93ca.json', ) .then((res) => res.json()) .then(async (res) => { const container = document.getElementById('container'); const s2DataConfig: S2DataConfig = { fields: { rows: ['province', 'city'], columns: ['type', 'sub_type'], values: ['number'], }, meta: res.meta, data: res.data, }; const s2Options: S2Options = { width: 600, height: 480, dataCell: (viewMeta, spreadsheet) => { return new CustomDataCell(viewMeta, spreadsheet); }, }; const s2 = new PivotSheet(container, s2DataConfig, s2Options); await s2.render(); });
No response
setTimeout之后访问test属性,又恢复成了原始值
希望可以保持修改后的值
The text was updated successfully, but these errors were encountered:
你好 @li1615882553:
⚠️ 在提出问题前,请确保你已经仔细阅读👓/搜索🔍过 官方文档 和 常见问题 以及 图表示例, 并且已经搜索查阅过相关 Issues 列表 和 Discussions 列表. 当你确定自己的问题没有解决方案时,请提交 issue。 ⚠️
如果是使用问题,不知道怎么用,移步 Discussions 讨论区 并提供 有效信息 进行 提问。
这是一个开源项目, 我们也有繁忙的业务要做, 是用自己的业余时间在维护, 为爱发电, 精力有限, 所以有时候 issue 响应速度不是那么及时, 如果你遇到了问题, 或者对 Issues 和 Discussions 列表的问题感兴趣, 可以直接认领并尝试修复 (贡献指南),帮助 S2 变得更好, 而不是一味的埋怨和催促, 我们不是甲方乙方的关系.
Sorry, something went wrong.
dataCell 的值是由创建实例时的 viewMeta 决定的
dataCell: (viewMeta, spreadsheet) => { return new CustomDataCell(viewMeta, spreadsheet); }
如果想自定义一些属性,这样即可
dataCell: (viewMeta, spreadsheet) => { + return new CustomDataCell({...viewMeta, test: 1}, spreadsheet); } drawBackgroundShape() { super.drawBackgroundShape(); this.meta.test = 2; //在这里修改属性 console.log('before test', this.meta.test); setTimeout(() => { console.log('after test', this.meta.test); //之后访问又恢复成了1 }) }
No branches or pull requests
🏷 S2 Version / S2 版本
💻 Sheet Type / 表格类型
🖋 Describe the bug / 问题描述
自定义单元格中,我想加一些单元格自己的数据,所以就加了几个属性,但是属性的修改看起来没有生效,在渲染完成后,属性会恢复为初始值
⌨️ Code Snapshots / 代码片段
🔗 Reproduction link / 复现链接
No response
📋 Steps to Reproduce the Bug or Issue / 重现步骤
setTimeout之后访问test属性,又恢复成了原始值
😊 Expected Behavior / 期望行为
希望可以保持修改后的值
😅 Current Behavior / 当前行为
No response
💻 OS / 操作系统
🌏 Browser / 浏览器
The text was updated successfully, but these errors were encountered: