DadyByte
DadyByte

Reputation: 914

Antd Table in React

I am creating a react app using antd in React. I want to create an Antd Table.

I am following this syntax: https://ant.design/components/table/#components-table-demo-jsx

In the dataSource I don't want separate names like firstName or lastName. I want one array object

name:["firstName","lastName"]

The problem is I am not able to load or render this data in the <Column /> tag inside the <Table /> tag.

Upvotes: 2

Views: 11839

Answers (2)

Preeti Patel
Preeti Patel

Reputation: 84

const columns = [
        { 
            title: 'Name', 
            dataIndex: ['firstName', 'lastname'],
            key: 'firstName',
            render: (row) =><> {row["firstName"]} {row["lastname"]}</>
        }
 ];

Upvotes: 0

blastz
blastz

Reputation: 365

You can render the column by your self like this

<Column
    title="First Name"
    key="firstName"
    render={(text, record) => (
        <div>{record.name[0]}</div>
    )}
/>

Upvotes: 6

Related Questions