如何更改 Ant 表头复选框

编程入门 行业动态 更新时间:2024-10-13 06:14:33
本文介绍了如何更改 Ant 表头复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我的应用程序中有一个表,我在其中对每一行使用 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-20 08:52:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/980061.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表头   复选框   如何更改   Ant

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!