Nested Reference Field

Nested Reference Field

react-admin reference field
react-admin nested resource
react-admin single field list
react-admin simpleshowlayout
react-admin custom filter
react-admin autocomplete input
react-admin list data
react-admin rowclick

In order to retrieve the equipment type I am using a that will retrieve the equipment model and then another that references the equipment type using the equipment model's field "typeID" to retrieve the equipment type.

However it displays the following warning:

Warning: Failed prop type: Invalid prop translateChoice of type boolean supplied to ReferenceField, expected function.

The image represents the data model (an equipment has an equipment model, and an equipment model has an equipment type)


Not a perfect fix, but to get around the translateChoice issue, you can create a wrapper and pluck out that prop to prevent it from being passed.

const SubReference = ({ translateChoice, children, ...props }) => (
    <ReferenceField {...props}>{children}</ReferenceField>
);

While troubleshooting this, I was also receiving an error about nested a tags. I was able to silence the error by setting the linkType prop to false in the parent ReferenceField

<ReferenceField source="item_id" reference="list" linkType={false}>
    <SubReference source="id_to_reference_from_list" reference="second_list">
        <TextField source="name" />
    </SubReference>
</ReferenceField>

Nested Reference Field · Issue #2140 · marmelab/react-admin , Warning: Failed prop type: Invalid prop translateChoice of type boolean supplied to ReferenceField , expected function . The image represents  The user field is mapped as type nested instead of type object. This query doesn’t match because Alice and Smith are not in the same nested object. This query matches because Alice and White are in the same nested object. inner_hits allow us to highlight the matching nested documents.


I found a better solution is kinda of an hack but seems to be more efficient.

Taking the question example where in order to get equipmentType is only needed <ReferenceField>, it would be something like this:

    const EquipList = ({...props}) => {
      <List {...props}>
        <Datagrid>

          <ReferenceFieldController label="Equipment Type" reference="equipmentModel" source="modelID" linkType={false}>
            {({referenceRecord, ...props}) => (
              <ReferenceField basePath="/equipmentModel" resource="equipmentModel" reference="equipmentType" source="typeID" record={referenceRecord || {}} linkType="show">
                <TextField source="name" />
              </ReferenceField>
            )}
          </RefenceFieldController>

        </Datagrid>
      </List>
    }

In the example above <ReferenceFieldController> fetches the equipmentModel of equipment, as like <ReferenceField>. Label is needed because RA uses the first <ReferenceField> to show the column header in <Datagrid>, if you use internationalization you should apply translate function to the correct resource on this prop.

<ReferenceController> fetches the record and passes it as referenceRecord to a child function that will render the component for field presentation. Instead of presenting the field component you render a <ReferenceField> to fetch the nested relation and next you show the field. Since <ReferenceFieldController> only passes controller props to its child and the props of field component don't do what you want in the nested relation, you have to explicit pass them to <ReferenceField>. You need to pass record of <ReferenceField> as referenceRecord || {} because the initially the referenceRecord is not fetched yet and <ReferenceField> doesn't work with record as null.

Setting the linkType of <ReferenceFieldController> to false makes it not render a <Link> component that would redirect the user to an incorrect route.

Nested reference fields used as display values display as sys_ids , Create a reference field to cmn_location on testtable1 and set it as the table's display value. For more information, see the product documentation  A nested type has access to all of the members that are accessible to its containing type. It can access private and protected members of the containing type, including any inherited protected members.


I have the same problem and I think this is an actual bug. I commented on the corresponding github issue https://github.com/marmelab/react-admin/issues/2140

I looked into the code for ReferenceField and as far as I understood this is an actual bug. ReferenceField expects a function for the translateChoice property, but internally hands a boolean to ReferenceFieldView. If you nest one ReferenceField into another the inner one receives false as translateChoice property and rightfully complains that it is a boolean and not a function.

Nested Reference Field, Ask questionsNested Reference Field. In order to retrieve the equipment type I am using a <ReferenceField> that will retrieve the equipment model and then  For many legacy SQL queries, BigQuery can automatically flatten the data. For example, many SELECT statements can retrieve nested or repeated fields while maintaining the structure of the data, and WHERE clauses can filter data while maintaining its structure.


How to access nested reference fields in openoffice reports., Am trying to enhance my open office report data with few more additional data. But am not able to access the nested referenced table values in to my report  The nested query searches nested field objects as if they were indexed as separate documents. If an object matches the search, the nested query returns the root parent document.


Nested datatype | Elasticsearch Reference [7.6], Using nested fields for arrays of objectsedit. If you need to index arrays of objects and to maintain the independence of each object in the array, you should use  Nested within the 'Applications' gallery is a Horizontal Gallery listing 'Functions' - from a datasource called 'Functions' filtered on the App Code from the 'Applications' Gallery Control; These are displaying as expected.


Java Precisely, a new reference type C. The class-body may contain declarations of fields, constructors, methods, nested classes, nested interfaces, and initializer blocks. Nested {IF} Fields. One {IF} can be used inside of another one to give logical branches and twists. {IF {PAGE} = 1 "This is the first page." "{IF {PAGE} < {NUMPAGES} "Page {PAGE} of {NUMPAGES}" "{NAME \p}" }"} This is called "nesting." The nested IF field is used if the first expression is false.