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

[data grid] Actions Navigate #15902

Open
aress31 opened this issue Dec 15, 2024 · 3 comments
Open

[data grid] Actions Navigate #15902

aress31 opened this issue Dec 15, 2024 · 3 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: logic Logic customizability new feature New feature or request

Comments

@aress31
Copy link

aress31 commented Dec 15, 2024

Summary

Since hooks cannot be directly used within valueGetter or getActions, I suggest providing pre-built actions, such as navigation, opening modals, and more. This would enable a much broader range of use cases, such as integrating with React Router actions or parsing URL parameters to control modal visibility.

Currently, hooks need to be passed to the function that creates the columns. In complex applications where column creation occurs several levels above the components using them, this adds unnecessary complexity. Allowing the use of function callbacks or offering pre-built actions would simplify integration and enhance flexibility.

Examples

No response

Motivation

No response

Search keywords: datagrid, action, navigate

@aress31 aress31 added new feature New feature or request status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 15, 2024
@github-actions github-actions bot changed the title [DataGrid] Actions Navigate [data grid] Actions Navigate Dec 15, 2024
@michelengelen
Copy link
Member

Hey @aress31 ... the idea behind makes perfect sense.
We do have some methods on the GridApi to show/hide the panels programmatically, though. Wouldn't these be sufficient for what you are trying to do?

GridApi docs

@michelengelen michelengelen added component: data grid This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 16, 2024
@aress31
Copy link
Author

aress31 commented Dec 16, 2024

@michelengelen, let me give you this use case:

const DataGridView = () => {
  // --- SNIP ---

  const modal = useModal();
  const [refineCoreProps, setRefineCoreProps] = useState({ action: "create" });

  const openModal = (action, id) => {
    setRefineCoreProps({ action, id });
    modal.show();
  };

  return (
    <Box>
      <DataGridComponent
        columns={
          loadingColumns || loadingData
            ? []
            : createColumns(supabaseColumns, meta, openModal)
        }
        // --- SNIP ---
        slotProps={{ toolbar: { openModal } }}
      />
      <FormDialog
        modalProps={{ modal, refineCoreProps }}
        // --- SNIP ---
      />
    </Box>
  );
};

I have a FormModal alongside the DataGrid with controls for various actions in the toolbar, however, I also have some other controls for the same toolbar as part of the datagridActions, my work around is to pass the openModal hook and then dynamically create the action columns - I am sure there could be much more efficient ways to achieve that by maybe defining hooks/callbacks, that could then be used directly within the actions without having to pass them down the entire tree.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Dec 16, 2024
@michelengelen
Copy link
Member

OK, makes sense. I'll add this to the board for the team to have a look and estimate.
Thanks for providing a use case as well ... It really helps in determining what there is to be imporoved! 👍🏼

@michelengelen michelengelen added customization: logic Logic customizability and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 16, 2024
@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: logic Logic customizability new feature New feature or request
Projects
Status: 🆕 Needs refinement
Development

No branches or pull requests

2 participants