national-gold
national-goldβ€’3y ago

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
8 Replies
national-gold
national-goldOPβ€’3y ago
using useTable
fair-rose
fair-roseβ€’3y ago
HeyπŸ‘‹ Can you also share the error?
national-gold
national-goldOPβ€’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
national-gold
national-goldOPβ€’3y ago
am getting in table props i want to show unit_name in table column
No description
national-gold
national-goldOPβ€’3y ago
@alicanerdurmaz can u help me with this?
fascinating-indigo
fascinating-indigoβ€’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}
national-gold
national-goldOPβ€’3y ago
ok thanks
fair-rose
fair-roseβ€’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:
["sub_department", "department", "org_units_departments", "0", "organization_unit", "unit_name"]
["sub_department", "department", "org_units_departments", "0", "organization_unit", "unit_name"]
If you need to handle multiple values, @salihozdemir's solution is better to give you control on what to render πŸš€