Code Monkey home page Code Monkey logo

Comments (6)

RhysOnlyBetter avatar RhysOnlyBetter commented on July 18, 2024 1

@cherniavskii Thanks for the response, I thought that by adding hideable: false it would force the column to always be shown, which was the opposite of what I'm looking for. I think with a combination of your example and adding slotProps with

columnsPanel: {
    getTogglableColumns: (columns: GridColDef[]) =>
      columns.filter((col) => col.hideable).map((col) => col.field),
  },

I have a solution I'm happy with.

Thanks again 😄

from mui-x.

michelengelen avatar michelengelen commented on July 18, 2024

Hey @RhysOnlyBetter,
I will try to answer your questions 1 by 1.

  1. Filter by id:
    Since you have a valueGetter function defined this is no longer possible, but you could change that to a valueFormatter function which is being used for displaying the cell value (when exporting as well)

  2. Shadow col:
    Yes, that would also be possible, by adding a filter function to slotProps.columnsPanel.getTogglableColumns. Here is the related docs section: customize togglable columns

Important

The naming for that slotProp got changed in v7
v6 => slotProps.columnsPanel.getTogglableColumns
v7 => slotProps.columnsManagement.getTogglableColumns

That way you can hide the col from the panel.

Does that help you?

from mui-x.

RhysOnlyBetter avatar RhysOnlyBetter commented on July 18, 2024

Thanks for the response @michelengelen.

  1. Unfortunately valueFormatter won't work for me since I need to sort and use the quick filter based on the formatted value.
  2. Thanks for the suggestion on getTogglableColumns, I'll add that to my original solution.

Do you think it would be a reasonable feature request to add an option to GridColDef to shadow columns so this was a bit easier?

Thanks again for your help!

from mui-x.

michelengelen avatar michelengelen commented on July 18, 2024

IMO the approach with the method provides a lot more freedom and customizability.

WDYT @mui/xgrid ? would adding a property to the coldef make sense?

from mui-x.

cherniavskii avatar cherniavskii commented on July 18, 2024

@RhysOnlyBetter

I apply a valueGetter function to these to get the cell value I want to display (value) => thingValuesMap.get(value).name

This makes sense to me.

I'm now adding the ability to pass filters to my table component via queryParams, and need to filter by the raw thingId value.

How about adding a separate column and using columnVisibilityModel to hide it?
Here is a working demo: https://stackblitz.com/edit/react-kms7xe?file=Demo.tsx,package.json
What do you think?

from mui-x.

github-actions avatar github-actions commented on July 18, 2024

⚠️ This issue has been closed.
If you have a similar problem, please open a new issue and provide details about your specific problem.
If you can provide additional information related to this topic that could help future readers, please feel free to leave a comment.

How did we do @RhysOnlyBetter?
Your experience with our support team matters to us. If you have a moment, please share your thoughts through our brief survey.

from mui-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.