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] How to override grid density factors to change what Compact/Standard/Comfortable means? #7251

Closed
2 tasks done
yay opened this issue Dec 19, 2022 · 2 comments
Closed
2 tasks done
Labels
component: data grid This is the name of the generic UI component, not the React module! support: commercial Support request from paid users

Comments

@yay
Copy link

yay commented Dec 19, 2022

Order ID 💳

48149

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

The problem in depth 🔍

Hi,

We need to use our custom row height values depending on the density selected and currently achieve this like so:

const getRowHeightByDensity = (density: DataGridPremiumProps['density']): number => {
  switch (density) {
    case 'standard': return 49;
    case 'compact': return 32;
    case 'comfortable': return 65;
    default: return 49;
  }
};

// then later in grid props
rowHeight={rowHeight || getRowHeightByDensity(gridProps.density)}

I've noticed that the row height is set via inline style rather than CSS classes. I guess this is to support variable row height as well, not just 3 predefined row height settings.

If overriding what each density level means via CSS is not an option, is it possible to override the density factor constants?
Or is the way we currently handle this already optimal?

export const COMPACT_DENSITY_FACTOR = 0.7;
export const COMFORTABLE_DENSITY_FACTOR = 1.3;

Thanks.

Your environment 🌎

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@yay yay added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels Dec 19, 2022
@oliviertassinari oliviertassinari added the component: data grid This is the name of the generic UI component, not the React module! label Dec 19, 2022
@m4theushw m4theushw removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 19, 2022
@m4theushw m4theushw changed the title How to override grid density factors to change what Compact/Standard/Comfortable means? [data grid] How to override grid density factors to change what Compact/Standard/Comfortable means? Dec 19, 2022
@m4theushw
Copy link
Member

Or is the way we currently handle this already optimal?

Yes, that's the way we expect users would customize the final row height depending on the density.

For the header height we have a discussion in #602 (comment) about allowing to use CSS to customize the final header height.

@yay
Copy link
Author

yay commented Dec 19, 2022

Thank you!

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! support: commercial Support request from paid users
Projects
None yet
Development

No branches or pull requests

3 participants