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

Add SelectColumns and DatagridConfigurable #8274

Merged
merged 28 commits into from
Oct 21, 2022
Merged

Add SelectColumns and DatagridConfigurable #8274

merged 28 commits into from
Oct 21, 2022

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Oct 18, 2022

Enregistrement.de.l.ecran.2022-10-18.a.11.45.14.mov
  • Add <DatagridConfigurable> component
  • Add <DatagridConfigurable> story
  • Add <DatagridConfigurable> tests
  • Add <DatagridConfigurable> documentation
  • Add <SelectColumnsButton> component
  • Add <SelectColumnsButton> story
  • Add <SelectColumnsButton> tests
  • Add <SelectColumnsButton> documentation
  • Use them in the simple example
  • Fix memoryStore.removeItems

Closes #7973

docs/navigation.html Show resolved Hide resolved
docs/Datagrid.md Outdated Show resolved Hide resolved
docs/SelectColumnsButton.md Outdated Show resolved Hide resolved
docs/Datagrid.md Outdated Show resolved Hide resolved
docs/Datagrid.md Outdated Show resolved Hide resolved
Copy link
Contributor

@WiXSL WiXSL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you hide all columns, you can't change the config anymore after you have leave the view and come back again 😢

screenshot
screenshot2

@fzaninotto
Copy link
Member Author

@WiXSL Right. I'm not sure how to solve this, though. Any suggestion?

…le.tsx

Co-authored-by: Aníbal Svarcas <WiXSL@users.noreply.github.com>
Copy link
Contributor

@WiXSL WiXSL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to be annoying here, but I tried a simple show hidden column functionality with a DatagridConfigurable and it doesn't show the column at all even when the config hasn't been touched yet.
The exact same code works, replacing DatagridConfigurable with Datagrid

// In ra-ui-materialui/src/list/datagrid/DatagridConfigurable.stories.tsx
export const Basic = () => {
     // State to show column
    const [show, setShow] = React.useState(false);

    return (
        <PreferencesEditorContextProvider>
            <MemoryRouter>
                <Inspector />
                <Box display="flex" justifyContent="flex-end">
                    <InspectorButton />
                </Box>
                <Box p={2}>
                    <Button
                        onClick={() => {
                            setShow(true);
                        }}
                    >
                        Show
                    </Button>
                    <DatagridConfigurable
                        resource="books1"
                        data={data}
                        sort={{ field: 'title', order: 'ASC' }}
                        bulkActionButtons={false}
                    >
                        <TextField source="id" />
                        <TextField source="title" label="Original title" />
                        <TextField source="year" />
                        {show === true && <TextField source="author" />}
                    </DatagridConfigurable>
                </Box>
            </MemoryRouter>
        </PreferencesEditorContextProvider>
    );
};

@fzaninotto
Copy link
Member Author

I'm not sure I understand your remark. What's the use case for that?

@WiXSL
Copy link
Contributor

WiXSL commented Oct 20, 2022

I'm not sure I understand your remark. What's the use case for that?

Let's say a user uses permissions to show or hide a particular set of columns, plus now wants to have a DatagridConfigurable instead of a Datagrid, things may break.

@fzaninotto
Copy link
Member Author

Let's say that we're not supporting this for now ;)

Copy link
Contributor

@slax57 slax57 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 💪

docs/navigation.html Outdated Show resolved Hide resolved
@slax57 slax57 added this to the 4.5.0 milestone Oct 21, 2022
@slax57 slax57 merged commit 74eff39 into next Oct 21, 2022
@slax57 slax57 deleted the DatagridConfigurable branch October 21, 2022 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants