In Antd is there a way to show the text in table cell into several lines.
I try to put </br>
, \n, \r into the text.
Is there someone who has already find a way to do that?
Rows can be selectable by making first column as a selectable column. You can use rowSelection.type to set selection type. Default is checkbox . selection happens when clicking checkbox by default.
Once you define sorter it's used for all the dataSource . So, once you click on sorted column - all your data gets sorted. Not very obvious, but you can take a look at this example. If you sort by age - the whole table data gets sorted.
You can make use of the responsive property on the column that you want to control for screen sizes. Just add a From To column with a custom render function, and set the responsive property on that column to only show on xs screens. The From and To columns will have the responsive property set to show on md and above.
Finally here is my solution.
The text for each column contains an \n when there is necessary to have a new line.
After into the table definition I put the style whiteSpace: 'pre':
<Table style={{ whiteSpace: 'pre'}} columns={columns} dataSource={data} title={title} .../>
Thats seems to work as expected.
In the hopes that it's never too late to answer a question here :D
Use the renderer of the table cell, like below, where you can use HTML tags (I'm using React so it's formatted as ReactNode with <> </> parent elements):
const columns = [
{
title: "Start",
dataIndex: "start",
key: "start",
render: (text) => <>
<p>{text.split("@")[0]}</p>
<p>{text.split("@")[1]}</p>
</>
},
{
title: "Name",
dataIndex: "name",
key: "name",
render: (text) => text
}]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With