nested query in meta data
metaData: {
fields: [
"id",
"org_unit_id",
"created_at",
{ sub_department: { department: ["name"] } },
], }, i want to get name from department table i am geting error
], }, i want to get name from department table i am geting error
8 Replies
rare-sapphireOPβ’3y ago
using useTable
foreign-sapphireβ’3y ago
Heyπ Can you also share the error?
rare-sapphireOPβ’3y ago
dataSource
:
Array(1)
0
:
created_at
:
"2022-12-06T04:57:35.19712+00:00"
id
:
"765633d1-9e1e-4e76-9196-9492d3e63af4"
org_unit_id
:
"67395d6e-eb4c-4b28-8273-6d8ecbcabd1c"
sub_department
:
department
:
name
:
"OPD"
org_units_deparments
:
Array(1)
0
:
organization_unit
:
unit_name
:
"Health"
[[Prototype]]
:
Object
[[Prototype]]
:
Object
length
:
1
[[Prototype]]
:
Array(0)
[[Prototype]]
:
Object
name
:
"testing sub"
<Table.Column
title="Unit"
dataIndex={[
"sub_department",
"department",
"org_units_deparments",
"organization_unit",
"unit_name",
]}
i want to show unit_name in table but i am able to get in tableprops
rare-sapphireOPβ’3y ago
am getting in table props i want to show unit_name in table column
rare-sapphireOPβ’3y ago
@alicanerdurmaz can u help me with this?
optimistic-goldβ’3y ago
Hey @rehan1,
"org_units_deparments" is an array so you can not get table value like this.
<Table.Column
title="Unit"
dataIndex={[
"sub_department",
"department",
"org_units_deparments",
"organization_unit",
"unit_name",
]}
You should change the
dataIndex
and you need to use render
function to handle your value like below:
<Table.Column
title="Unit"
dataIndex={[
"sub_department",
"department",
"org_units_deparments",
]}
render={(value) => value[0].organization_unit.unit_name}rare-sapphireOPβ’3y ago
ok thanks
foreign-sapphireβ’3y ago
If
org_units_departments
is in array form but always with a single value or showing just a single one is enough; you can also define the dataIndex
as:
If you need to handle multiple values, @salihozdemir's solution is better to give you control on what to render π