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
Node.belongsCell不能同步获取,需使用异步方式才可以获取 Node.belongsCell目前使用setTimeout包裹或者 await 实现的sleep后 才能拿到。
const s2Options: S2Options = { style: { colCell: cellTextWordWrapStyle, }, }
const cellTextWordWrapStyle: CellTextWordWrapStyle = { height: (colNode) => { return 40; }, heightByField: { [EXTRA_FIELD]: 45, }, width: async (rowNode) => { // rowNode.belongsCell 同步时为undefind setTimeout(() => { rowNode.belongsCell.getActualText() }, 0) }, // 最大行数,文本超出后将被截断 maxLines: 2, // 文本是否换行 wordWrap: true, textOverflow: 'ellipsis', };
rowNode.belongsCell同步状态应该可以获取到cell
The text was updated successfully, but these errors were encountered:
布局的流程是 node => cell => layout
width: async (rowNode) => 这个 hook 调用的时候是在生成 node 的阶段, 请注意, 注入的参数是 rowNode, 而不是 rowCell, 是用于更改 node 的宽高, 此时还没有生成 cell, 获取不到是符合预期的, 这个和异步没关系.
width: async (rowNode) =>
rowNode
rowCell
你没有描述你具体用来做什么, 看起来是根据渲染的文本来调整宽度
你可以在 s2.render 之后拿到单元格信息, 然后再根据你自己的诉求更新 style
s2.render
const colCell = s2.facet.getColCells()[0] const text = colCell.getActualText() ...你自己的逻辑 s2.setOptions({ style: { colCell: { width: 宽度, }, }, }); s2.render(false)
PS: 粘贴代码请使用基本的 markdown 格式, 强迫症有点难受
Sorry, something went wrong.
lijinke666
No branches or pull requests
🏷 Version
Sheet Type
🖋 Description
Node.belongsCell不能同步获取,需使用异步方式才可以获取
Node.belongsCell目前使用setTimeout包裹或者 await 实现的sleep后 才能拿到。
⌨️ Code Snapshots
🔗 Reproduce Link
🤔 Steps to Reproduce
const s2Options: S2Options = {
style: {
colCell: cellTextWordWrapStyle,
},
}
const cellTextWordWrapStyle: CellTextWordWrapStyle = {
height: (colNode) => {
return 40;
},
heightByField: {
[EXTRA_FIELD]: 45,
},
width: async (rowNode) => {
// rowNode.belongsCell 同步时为undefind
setTimeout(() => {
rowNode.belongsCell.getActualText()
}, 0)
},
// 最大行数,文本超出后将被截断
maxLines: 2,
// 文本是否换行
wordWrap: true,
textOverflow: 'ellipsis',
};
😊 Expected Behavior
rowNode.belongsCell同步状态应该可以获取到cell
😅 Current Behavior
💻 System information
The text was updated successfully, but these errors were encountered: