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 & CRUD 设置自动适应高度后行操作按钮位置计算错误 #9231 #9235

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions docs/zh-CN/components/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,47 @@ popOver 的其它配置请参考 [popover](./popover)
}
```

## 行操作按钮(固定高度)

通过 itemActions 可以设置鼠标移动到行上出现操作按钮

```schema: scope="body"
{
"type": "service",
"api": "/api/mock2/sample?perPage=10",
"body": [{
"type": "table",
"source": "$rows",
"autoFillHeight": {height: 300},
"itemActions": [{
"label": "编辑",
"type": "button",
"actionType": "dialog",
"dialog": {
"title": "编辑",
"body": "这是个简单的编辑弹框"
}
}, {
"label": "删除",
"type": "button",
"actionType": "ajax",
"confirmText": "确认要删除?",
"api": "/api/mock2/form/saveForm"
}],
"columns": [{
"name": "browser",
"label": "Browser"
},

{
"name": "version",
"label": "Version"
}
]
}]
}
```

## 单行点击操作

> 1.4.0 及以上版本
Expand Down
4 changes: 3 additions & 1 deletion packages/amis/src/renderers/Table/ItemActionsWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ function ItemActionsWrapper(props: ItemActionsProps) {
return;
}
const rect = dom.getBoundingClientRect();
let frameScrollTop = frame?.parentElement?.scrollTop || 0;
const height = rect.height;
const top =
rect.top -
frame.getBoundingClientRect().top +
parseInt(getComputedStyle(frame)['marginTop'], 10);
parseInt(getComputedStyle(frame)['marginTop'], 10) -
frameScrollTop;
divRef.current!.style.cssText += `top: ${top}px;height: ${height}px;`;
}, [store.hoverRow?.id]);

Expand Down
Loading