如何更改 Ant 表头复选框 [英] How to change Ant table header checkbox

查看:59
本文介绍了如何更改 Ant 表头复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个表,我在其中对每一行使用 select.

当我点击并选择行时,左上角会出现一个选中的复选框.我不想显示该复选框,我想显示其他内容,例如带有文本的 div.只有当我单击一行中的复选框时,该 div 才会出现.

如何做到这一点?我试图找到呈现该复选框的事件,但我没有找到.如何访问该元素并在其他元素中更改它?沙箱链接:

I have a table in my application, where I use select for each row.

When I click on and select row, on the top-left corner appears a checked checkbox. I don't want to display that checkbox, I want to display something else, a div with a text for example. That div should appear only when I click on a checkbox from a row.

How to do this? I tried to find the event that renders that checkbox, but I didn't manage. How to access that element and to change it in other else? link to sandbox: https://codesandbox.io/s/selection-ant-design-demo-vlftk?file=/index.js

解决方案

We can set custom component to columnTitle inside props rowSelection of <Table />

Set the title of the selection column
Type: string|React.ReactNode

Refer: document of Antd Table rowSelection

const rowSelection = {
  columnTitle: selectedRowKeys.length > 0 ? <div>XXX</div> : <></>,
  ...
}

<Table rowSelection={rowSelection} />;

这篇关于如何更改 Ant 表头复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆