react antd Table 表格 td超出自动换行

75 篇文章 0 订阅
61 篇文章 1 订阅

1.问题:

目前有打印需求遇到了点问题,打印时表头太长导致出现横向滚动条,而借助于 react-to-print只能打印出视图区可见内容,所以打印的时候滚动条里面的内容没打印到。

现在为了完整打印页面内容,只能让表格列超过换行,这样才不会出现滚动条。

2.解决:

我们需要将列 colums数组项使用render函数渲染,添加whiteSpace:'pre-wrap'样式。

const columns = [
    { title: '序号', dataIndex: 'index', valueType: 'index', width: 48, fixed:'left'},
    { title: '客户', dataIndex: 'client', valueType: 'select', valueEnum: customerOptions, 
      fieldProps:{ showSearch: true }
    },
    { title: '发货', dataIndex: 'deliver', hideInSearch: true, width: 120},
]
columns.forEach((item,index)=>{
	if(index){
		item.render = (a,param)=>[
			<div style={{whiteSpace:'pre-wrap'}}>{param[item.dataIndex]}</div>
		]
	}
})    
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值