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

EditableProTabl自定义操作栏问题 #11073

Closed
northlane286 opened this issue Dec 4, 2023 · 1 comment
Closed

EditableProTabl自定义操作栏问题 #11073

northlane286 opened this issue Dec 4, 2023 · 1 comment

Comments

@northlane286
Copy link

northlane286 commented Dec 4, 2023

🧐 问题描述 | Problem description

在使用EditableProTable的时候自定义操作栏只返回一个删除按钮时当我提交或重置时为什么无法让表格回到初始化的样子,再次提交或重置时才可以,有没有大佬指点一下

💻 示例代码 | Sample code

<EditableProTable
rowKey="line_id"
bordered={true}
editableFormRef={editableFormRef}
controlled
actionRef={actionRef}
formItemProps={{
rules: [
{
validator: async (_, value) => {
if (value.length < 1 || !value[0].product_name) {
throw new Error('请至少添加一个商品');
}
if (value.length > 5) {
throw new Error('最多可以添加5个商品');
}
},
},
],
}}
maxLength={10}
name="goodsList"
columns={columns}
recordCreatorProps = {false}
editable={{
type: 'multiple',
editableKeys,
onChange: setEditableRowKeys,
actionRender: (row, config, defaultDom) => {
if(row.product_no) {
return [defaultDom.delete];
}
return [];
},
onDelete:async (key,row)=>setIndex(index-1),
}}
/>

🚑 其他信息 | Other information

这是提交或重置的样子
Uploading 1701657043261.jpg…

@chenshuai2144
Copy link
Collaborator

在使用EditableProTable时,你自定义操作栏只返回了一个删除按钮。当你提交或重置表格时,无法让表格回到初始化的样子,需要再次提交或重置才可以。这个问题可能是因为你没有正确处理表格的重置操作。

要解决这个问题,你可以在重置操作时,手动将editableKeys重置为空数组,即setEditableRowKeys([])。这样就可以让表格回到初始化的状态。在提交操作时,你也需要根据实际需求来处理相关的逻辑。

另外,你还提到有很多按钮组,想确定它们的顺序。一般来说,我们会按照以下逻辑来确定按钮的顺序:

  1. 业务逻辑:将「推进」进程的操作放在前面,例如编辑、新建、发布、保存、取消、撤回等。
  2. 视图控制:控制内容展示形式的操作,例如全屏、表格密度、放大缩小、布局控制等。
  3. 其他:放置刷新、分享、设置等操作。
  4. 溢出:如果按钮组过多,在响应式设计中可以将一部分操作放到溢出菜单中。

希望这些解答能对你有帮助!如果还有其他问题,请随时提问。

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

No branches or pull requests

2 participants