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] Make value and colDef accessible in actions column #15667

Open
aress31 opened this issue Nov 29, 2024 · 2 comments
Open

[data grid] Make value and colDef accessible in actions column #15667

aress31 opened this issue Nov 29, 2024 · 2 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! customization: extend Logic customizability new feature New feature or request status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@aress31
Copy link

aress31 commented Nov 29, 2024

Summary

The params in getActions are only row, id and and columns; there is no information about the currently processed column or value which is quite restrictive when using type mappings. Addin them would improve DX and remove boilerplate code.

Examples

const getTypeMappings = (field) => ({
  // --- SNIP ---
  bytea: {
    headerName: undefined,
    type: "actions",
    getActions: ({ row }) => {
      const dataUrl = hexStringToDataUrl(row[field]);
      return [
        <GridActionsCellItem
          onClick={() => downloadFile(dataUrl)}
          icon={<Download />}
          label="Download"
          disabled={!dataUrl}
        />,
      ];
    },
  },
  // --- SNIP ---
});

Note: Also, transformations within valueGetter don't seem accessible to getActions too.

Motivation

Improve the DX and provide contextual info to getActions.

Search keywords: actions

@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 Nov 29, 2024
@michelengelen
Copy link
Member

Hey @aress31 ... why would you need a value or valueGetter in getActions? The actions col is a special column which purpose is simply to render a series of buttons that perform actions on the row in question. That's exactly why we pass the row as a property to it.

Could you explain your specific use case please?

@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 customization: extend Logic customizability and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 29, 2024
@michelengelen michelengelen changed the title [DataGridAction] Make value and colDef accessible [data grid] Make value and colDef accessible in actions column Nov 29, 2024
@aress31
Copy link
Author

aress31 commented Nov 29, 2024

@michelengelen simply because my action column need contextual information such as the current value/column name to process the action logic. See the code snippet in my opening message.

@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 Nov 29, 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: extend Logic customizability new feature New feature or request status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

2 participants