2

I have a list of 6k entries related to a ressource.

I would like to be able to list, search and paginate over them in a TabbedForm/FormTab. ReferenceManyField shows a limited number of entries.

What is the recommended way to extend ReferenceManyField or use List instead?

Fonzarely
  • 445
  • 4
  • 11

2 Answers2

3

You can use the DataGrid component to large number of entries. I think there might be confusion on your part about List. List only fetches records and the actual rendering is done by DataGrid.

ReferenceManyField accepts filter, sort etc. parameters which you can use to control the number of records being fetched from your API.

kunal pareek
  • 1,285
  • 10
  • 21
2

According to those two issues: https://github.com/marmelab/admin-on-rest/issues/998 and https://github.com/marmelab/admin-on-rest/issues/561 you cannot use List in ReferenceManyField and the suggested way to do it is having a button that redirects you to the related List component with the proper filter.

Example:

class LinkToRelatedReviews extends React.Component {
    render() {
    return (<FlatButton
        primary
        label={ translate("Full list of reviews by user") }
        icon={<ReviewsIcon />}
        containerElement={
            <Link to={{
                pathname: '/reviews',
                search: stringify({ filter: JSON.stringify({ userId: [this.props.params.id] }), page: 1 }),
            }}
        />}
    />)
    }
}

export default LinkToRelatedReviews;

Something like that can be put in UsersShow Component

<LinkToRelatedReviews params={props.match.params}/>

under DataGrid that doesn't provide pagination but can fetch some of the results for you.

You can also see it in action by navigating to: https://marmelab.com/admin-on-rest-demo/#/segments and clicking Customers. This will redirect you to CustomersList filtered by the specific segment.

Michail Michailidis
  • 11,792
  • 6
  • 63
  • 106