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

feat(table ): EditableProTable支持自定义渲染新建按钮 #8806

Conversation

louhaojie99
Copy link

@louhaojie99 louhaojie99 commented Oct 18, 2024

需求场景:默认的新建按钮在禁用时可加入 Tooltip 提示信息;原本已有的 API 无法满足这一诉求。

<EditableProTable>
  recordCreatorProps={{
    record: () => ({}),
    disabled: true,
  }}
  renderCreatorButton={(originNode) => {
    return <Tooltip title="禁用时提示文本">{originNode}</Tooltip>;
  }}
/>

效果图

image

Copy link

github-actions bot commented Oct 18, 2024

⚡️ Deploying PR Preview...

@louhaojie99 louhaojie99 force-pushed the feat/edit-table-render-creator-button branch 3 times, most recently from cd33ba1 to ffe0c29 Compare October 18, 2024 13:22
@louhaojie99 louhaojie99 force-pushed the feat/edit-table-render-creator-button branch from ffe0c29 to cdabd6f Compare October 18, 2024 13:40
@chenshuai2144 chenshuai2144 changed the title feat(EditableProTable): 可编辑表格支持自定义渲染新建按钮 feat(table ): EditableProTable支持自定义渲染新建按钮 Oct 22, 2024
{creatorButtonText ||
intl.getMessage('editableTable.action.add', '添加一行数据')}
</Button>
<>{renderCreatorButton?.(originNode) ?? originNode}</>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有几个疑惑,不知道我的描述有没有问题,你帮忙看看:

  1. 这里的 useMemo 没有吧 renderCreatorButton 添加到依赖项中会不会有其他问题,或者说我们需要 usememo 么?
  2. 原来的 recordCreatorProps !== false 提前短路了,但是这个 PR 提升了一个 originNode 变量,应该可以把 recordCreatorProps 判断再往前移一下提前段路掉 if(recordCreatorProps) { xxx }

@chenshuai2144
Copy link
Contributor

把这两个 api 收到一起吧。createButtonConfig:{render, buttionProps},
外面放的已经有点多了

@louhaojie99
Copy link
Author

把这两个 api 收到一起吧。createButtonConfig:{render, buttionProps}, 外面放的已经有点多了

好的,我来修改一下,稍后提一个新的 PR.

recordCreatorProps={{
 // 原有的 buttonProps 不变
  ...
   
 // 新特性: 自定义渲染(满足按钮禁用加提示场景等...)
  render
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants