1

Is there some way how to access Datagrid row value in react admin. I have code:

const OrdersDatagrid = function() {
        let fakeProps = {
            basePath: "/api/orders",
            hasCreate: false,
            hasEdit: false,
            hasList: true,
            hasShow: false,
            bulkActionButtons: false,
            sortable: false,
            exported: false,
            history: {},
            options: {},
            permissions: null,
            resource: "orders"
        }

        return (
            <>
                <List {...fakeProps}>
                    <Datagrid>
                        <ReferenceField source="customer" label="Customer" reference="customers">
                            <TextField source="fullName" label="name"/>
                        </ReferenceField>
                        <TextField source="state" label="State"/>
                    </Datagrid>
                    <SomeComponent
                        customer={customer}
                    />
                </List>
            </>
        )

    } 

And I want to access value customer and pass it to SomeComponent. How can i do it? Is it possible?

SpartanRA
  • 11
  • 3
  • Can you clarify what you are trying to do a bit more? It sounds like you might want to use an Aside component https://marmelab.com/react-admin/List.html#aside-aside-component – John McCabe Sep 17 '21 at 19:25

3 Answers3

1

You could use Function Field

<FunctionField render={record => <SomeComponent customer={record.customer /> } />

Miguel Araya
  • 404
  • 3
  • 10
1

You can use the below code to reach Datagrid row value, I am also showing an icon preview.

<FunctionField label="icon" render={record => <Icon>{record.icon}</Icon> } />
kyun
  • 9,710
  • 9
  • 31
  • 66
0

I think this is what you need:

<SomeComponent
    record={props.record}
    source="customer"
/>

But you should use it inside the <Datagrid>.