Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatagridConfigurable doesn't work with both filters and actions #8406

Closed
adamjq opened this issue Nov 19, 2022 · 2 comments · Fixed by #8417
Closed

DatagridConfigurable doesn't work with both filters and actions #8406

adamjq opened this issue Nov 19, 2022 · 2 comments · Fixed by #8417

Comments

@adamjq
Copy link

adamjq commented Nov 19, 2022

I've tried to use the DatagridConfigurable component from the docs https://marmelab.com/react-admin/Datagrid.html under Showing / Hiding Columns but it's removing the filters I've already configured. The docs suggest that both filters and actions should be compatible. I'm using the ra-data-graphql-simple library to provide data.

What you were expecting:
DatagridConfigurable to display both the SelectColumnsButton and Add Filter sections.

What happened instead:
Adding SelectColumnsButton and DatagridConfigurable added an option to select columns but removed the Add Filter section.

The search bar defined in the filters still displays and works.

Related code:

import React from 'react';
import { List, DatagridConfigurable, TextField, TextInput, NumberInput, TopToolbar, SelectColumnsButton } from 'react-admin';

const userFilters = [
    <TextInput label="Search by Email" source="q" alwaysOn />,
    <NumberInput label="id" source="id"/>,
];

const UserListActions = () => (
    <TopToolbar>
        <SelectColumnsButton />
    </TopToolbar>
);

export const UserList = (props: any) => {
    return (
        <List {...props} actions={<UserListActions />} filters={userFilters}>
            <DatagridConfigurable bulkActionButtons={false}>
                <TextField source="id" sortable={false}/>
                <TextField source="email" />
            </DatagridConfigurable>
        </List>
    );
};

Library versions

  "ra-data-graphql-simple": "^4.4.3"
  "react": "^18.2.0"
  "react-admin": "^4.5.1"
  "react-dom": "^18.2.0"
  "react-scripts": "5.0.1"
@WiXSL
Copy link
Contributor

WiXSL commented Nov 21, 2022

Maybe we should improve the example in the docs. (https://marmelab.com/react-admin/Datagrid.html#showing--hiding-columns)

If you are passing the actions prop, you are responsible for adding every action button.

const UserListActions = () => (
    <TopToolbar>
        <SelectColumnsButton />
+      <FilterButton />
+      <CreateButton />
+      <ExportButton />
    </TopToolbar>
);

@adamjq
Copy link
Author

adamjq commented Nov 21, 2022

Great thanks @WiXSL - I tried that and it worked perfectly. I agree the documentation could be updated for that particular section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants