constructor(props) {
super(props)
this.state = {
fieldDdata: data,//操作动态columns的配置
columns: [],
tableDate: [],
}
}
<Table
columns={this.state.columns}
dataSource={this.state.tableDate}
/>
<Button
onClick={event => {
event.stopPropagation()
console.log("name", column)
// newColums
let newdata = this.state.fieldDdata.map(item => {
if (item.column === column) {
item.selected = !selected
}
return i
}
let newColums = this.state.columns
if (content === "remove") {
//remove
newColums = newColums.filter(item => item.dataIndex !== column)
} else if (content === "add") {
//add
newColums.push({
title: column,
dataIndex: column,
key: column ,
//antd 的table td 超出部分隐藏并显示省略号
onCell: () => {
return {
style: {
maxWidth: 150,
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow:'ellipsis',
cursor:'pointer'
}
}
},
render: (text) => <Tooltip placement="topLeft" title={text}>{text}</Tooltip>
},
this.setState({
fieldDdata: newdata,
columns: newColums,
})
}}
>
{content}
</Button>
antd 的table td 超出部分隐藏并显示省略号
网友评论