show data from another table on show/id page
Hi, I'm using supabase as DB
Now I have a table named component_arrivals. on this table, I have a field named lot contain a list of lot from lot table. Now can I show the expire_date from lot table in component_arrivals show page?
8 Replies
Hi @tandeptraiso1. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Hmm, I don't know enough to give you a confident answer yet. However, based on the information provided in the extracts, you can use the
useMany
hook in Refine to fetch related data from another resource.
Here's a general example from the extracts:
In your case, you would replace IYourDataType
with the TypeScript interface of your lot
data, relatedResource
with "lot"
, and relatedIds
with the ids of the lots you want to fetch.
Then, you can use this data in your show page. However, the exact implementation would depend on your specific data structure and requirements.
For more detailed information, you might want to check out the Refine documentation (https://refine.dev/docs).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@369510721135837184> kapa.ai is still learning and improving, please let us know how it did by reacting below
deep-jadeOP•15mo ago
@kapa.ai I'm implemented by useList like this
now I want to show it on UI by
but the typescript for lot.manufacturing_number showing error Property 'manufacturing_number' does not exist on type 'IResourceComponentsProps<any, { [key: string]: any; }, ILogData>'
can you help me bypass this?
Let me check the knowledge base for you. One moment! :books:
----------------------
The TypeScript error you're encountering is because the
manufacturing_number
field is not defined in your IResourceComponentsProps
interface. TypeScript is a statically typed language, which means you need to define the types of your variables and objects upfront.
To resolve this issue, you need to ensure that the manufacturing_number
field is included in your IResourceComponentsProps
interface. Here's an example of how you can do this:
In this example, manufacturing_number
is defined as an optional string field. This means it can either be a string or undefined. If you're sure that manufacturing_number
will always be a string, you can remove the ?
to make it a required field.
After updating your interface, your useList
hook and map function should work as expected without TypeScript errors.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@369510721135837184> kapa.ai is still learning and improving, please let us know how it did by reacting below
deep-jadeOP•15mo ago
@kapa.ai I can get the list from supabase by useList like this
const { data: lotComponentsProps, isLoading: lotLoading } = useList<ILotComponentsProps>({
resource: "lot",
filters: [{
field: "manufacturing_number",
operator: "in",
value: record?.lot,
},],
queryOptions: {
enabled: !!record?.lot,
},
});
Now I want to display it inside the componentArrivals/show/id by antd table, can you help me?
Let me check the knowledge base for you. One moment! :books:
----------------------
Sure, you can display the data fetched with
useList
in an Ant Design Table. Here's a basic example of how you can do this:
In this example, dataSource
is set to the data you fetched with useList
. rowKey
is set to "id"
, assuming each of your data items has a unique id
field. If not, replace "id"
with the name of a unique field in your data.
Each Table.Column
represents a column in your table. The title
prop sets the column title, dataIndex
sets which field from your data should be displayed in this column, and key
is a unique identifier for this column.
You can add more Table.Column
components as needed to display more fields from your data.
Please replace "manufacturing_number"
and "id"
with the actual field names in your data if they are different.
For more detailed information, you might want to check out the Ant Design Table documentation (https://ant.design/components/table/) and the Refine documentation (https://refine.dev/docs).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@369510721135837184> kapa.ai is still learning and improving, please let us know how it did by reacting below