9

How could I hide the action buttons in the React-Admin 2.2.0 framework?

For example, I want to hide just the export button, or show only the Refresh and Export buttons.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Katliss.26
  • 412
  • 3
  • 9

1 Answers1

21

Well, I found the solution myself.

When you want to hide all buttons:

import { List, CardActions } from 'react-admin';

const NoneActions = props => (
    <CardActions />
);

export const AdminList = (props) => (
    <List title="Admin List" {...props} actions={<NoneActions />}>
        ...
    </List>
);

When you want to show only the reload Button:

import { List, CardActions, RefreshButton } from 'react-admin';

const ActionsRefresh = props => (
    <CardActions>
        <RefreshButton />
    </CardActions>
);

export const AdminList = (props) => (
    <List title="Admin List" {...props} actions={<ActionsRefresh />}>
        ...
    </List>
);
François Zaninotto
  • 7,068
  • 2
  • 35
  • 56
Katliss.26
  • 412
  • 3
  • 9
  • 2
    This is a very correct and readable solution! You can mark it as solved. It will help further readers +1 – Kmaschta Aug 27 '18 at 16:18
  • 1
    Wish I could more upvote this - The docs are pretty convoluted and force more complexity in their description without providing simple context. – richessler Nov 03 '18 at 05:35