Merge pull request #4895 from nwind/fix-table-view-td-style

fix: table-view 的边框只应该在 td 上设置
This commit is contained in:
RUNZE LU 2022-07-20 12:30:48 +08:00 committed by GitHub
commit 5657194347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 14 deletions

View File

@ -142,6 +142,71 @@ table view 的设置项有三层,可以分别对表格级别、行级别、单
| rowspan | `number` | | 单元格垂直跨几列 | | rowspan | `number` | | 单元格垂直跨几列 |
| body | [SchemaNode](../../docs/types/schemanode) | | 其它 amis 设置 | | body | [SchemaNode](../../docs/types/schemanode) | | 其它 amis 设置 |
#### 单元格样式示例
比如将其它两列的单元格边框设置为 0就能实现特殊的展现效果
```schema: scope="body"
{
"type": "table-view",
"trs": [
{
"background": "#F7F7F7",
"tds": [
{
"body": {
"type": "tpl",
"tpl": "地区"
}
},
{
"body": {
"type": "tpl",
"tpl": "城市"
}
},
{
"body": {
"type": "tpl",
"tpl": "销量"
}
}
]
},
{
"tds": [
{
"body": {
"type": "tpl",
"tpl": ""
},
"style": {
"borderBottomWidth": 0,
"borderLeftWidth": 0
}
},
{
"body": {
"type": "tpl",
"tpl": "北京"
}
},
{
"body": {
"type": "tpl",
"tpl": ""
},
"style": {
"borderBottomWidth": 0,
"borderRightWidth": 0
}
}
]
}
]
}
```
### 列设置项 ### 列设置项
列设置项主要是用于控制整列的样式,比如 列设置项主要是用于控制整列的样式,比如

View File

@ -190,7 +190,7 @@ export default class TableView extends React.Component<TableViewProps, object> {
width: td.width || 'auto', width: td.width || 'auto',
textAlign: td.align || 'left', textAlign: td.align || 'left',
verticalAlign: td.valign || 'center', verticalAlign: td.valign || 'center',
...style ...td.style
}} }}
align={td.align} align={td.align}
valign={td.valign} valign={td.valign}
@ -256,22 +256,12 @@ export default class TableView extends React.Component<TableViewProps, object> {
} }
render() { render() {
const { const {width, trs, classnames: cx, className} = this.props;
width,
border,
borderColor,
trs,
classnames: cx,
className
} = this.props;
let styleBorder;
if (border) {
styleBorder = `1px solid ${borderColor}`;
}
return ( return (
<table <table
className={cx('TableView', className)} className={cx('TableView', className)}
style={{width: width, border: styleBorder, borderCollapse: 'collapse'}} style={{width: width, borderCollapse: 'collapse'}}
> >
{this.renderCaption()} {this.renderCaption()}
{this.renderCols()} {this.renderCols()}