Code Monkey home page Code Monkey logo

Comments (26)

MBilalShafi avatar MBilalShafi commented on July 22, 2024 4

@achoud444 We do have documentation section for the API method getRowGroupChildren, but I agree we could add a recipe here for more users trying to achieve a similar thing.

I'll convert this issue to a recipe request.

from mui-x.

MBilalShafi avatar MBilalShafi commented on July 22, 2024 2

Hey @achoud444 I understand what you mean. I prepared a demo to achieve that: https://codesandbox.io/p/sandbox/great-waterfall-c2sm2j

I am assuming that all children of a given parent row should have the same value for createdAt field, so I am reading the first child row and using its value in the parent row. The trick is to use an API method getRowGroupChildren to get the children of each parent row and use them to extract the necessary value.

Let me know if this fulfills your requirements.

Sidenote: I used rowNode.type === 'group' instead of rowNode.depth === 0 as the latter may cause issues in multi-level grouping.

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024 1

Hey @achoud444
The grid can handle a tremendous amount of data.
We have customers using it with datasets that are 5M+

The bottleneck in this case would probably be the parsing of the data to the hidden column.

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024 1

@achoud444 this is something we cannot support ... at least not that I am aware of.
@MBilalShafi do you have an idea if we can somehow make this work?

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024 1

Technically you could listen on the event we use to adjust the column size, but I think this might prove to be quite the performance implication.

I am exploring right now if you can pass in a custom row renderer for the grouping row which could allow you to use a cell renderer for the "common cells" you mentioned

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024 1

Hey @achoud444 ... yes, you can do the same, but you would need to return the value or formattedValue from the renderCell function if it is not a grouping row!

Thanks for providing the initial demo @MBilalShafi ... I didn't have enough time to finish it! 💙

from mui-x.

achoud444 avatar achoud444 commented on July 22, 2024 1

@MBilalShafi thanks it does work for me. But How's a mere mortal supposed to know this? 😆

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024

Hey @achoud444 what you are trying to achieve is currently not possible.
Did you consider using tree data or row grouping feature.
Here are demos on how this would look like and work:

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024

Another way to achieve this would be to add a hidden column with all data from the nested data grid (stringified). here is a comment on a different issue with a demo on how this could look like: #12620 (comment)

from mui-x.

achoud444 avatar achoud444 commented on July 22, 2024

Hey, @michelengelen,

I have tried using the but
Row Grouping: After grouping the rows, I am unable to access or utilize other common fields within the grouped rows.
Tree Data: I am not sure how to implement tree data in this context.

from mui-x.

achoud444 avatar achoud444 commented on July 22, 2024

Another way to achieve this would be to add a hidden column with all data from the nested data grid (stringified). here is a comment on a different issue with a demo on how this could look like: #12620 (comment)

I'm considering adding a hidden column but I'm uncertain about its efficiency with large datasets.

How well can the data grid handle large amounts of data? For example, is there an estimated number of rows it can efficiently manage?

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024

I have tried using the but Row Grouping: After grouping the rows, I am unable to access or utilize other common fields within the grouped rows.

what do you mean by that? It should be possible to use any customization available for the rows as always. Could you elaborate?

Tree Data: I am not sure how to implement tree data in this context.

it really depends on the data structure, but for most cases it should be possible to use it.

from mui-x.

achoud444 avatar achoud444 commented on July 22, 2024

@michelengelen Please check this.

I want to keep created at only in the grouped row and also the buttons for download in the same row

from mui-x.

achoud444 avatar achoud444 commented on July 22, 2024

@michelengelen Hi! Can I resize the Master(child) table columns to align with the parent columns when the parent is resized?. Code

from mui-x.

MBilalShafi avatar MBilalShafi commented on July 22, 2024

I want to keep created at only in the grouped row and also the buttons for download in the same row

@achoud444 You can use renderCell to only render the action buttons in the group rows. For the created at column, since every child row has its own value, which value do you want to show in the group row?

renderCell: (params) => {
  if (params.rowNode.depth === 0) {
    // Group node
    return <ActionButtonsComponent />
  }
  return null
}

I did something similar in this CSB example: https://codesandbox.io/p/sandbox/festive-sunset-xr33js

Let me know if it helps.

from mui-x.

achoud444 avatar achoud444 commented on July 22, 2024

@MBilalShafi Can I do same for the createdAt date since it is same for the Company?

from mui-x.

achoud444 avatar achoud444 commented on July 22, 2024

@michelengelen When I use hardcoded value it reflects but when I use params.value it does not work.

{
    field: "createdAt",
    headerName: "Created at",
    type: "string",
    renderCell: (params) => {
      if (params.rowNode.depth === 0) {
        return (
          <span>
            {"ashish"}  //when I use params.value it does not work
          </span>
        );
      }
      return params.value;
    },
  },

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024

@achoud444 this is strange. Could you share the code you are using?

from mui-x.

achoud444 avatar achoud444 commented on July 22, 2024

@michelengelen please have a look link

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024

It's not public ... please open it up so I can have a look! 🙇🏼

from mui-x.

achoud444 avatar achoud444 commented on July 22, 2024

@michelengelen Please check now

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024

Ah, thats because for the grouping rows (those have the params.rowNode.depth === 0) there is no value.

This is the place where you would need to add your custom component to display in the grouping row

from mui-x.

achoud444 avatar achoud444 commented on July 22, 2024

@michelengelen Do you have an example to do that? And why we do not have any staright forward way to do that?

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024

Yes, the example was provided by @MBilalShafi here: #13505 (comment)

You can use the same pattern, but just return params.value or params.formattedValue from the function when params.rowNode.depth !== 0.

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024

This is quite the straight forward approach to do something like this. Otherwise we would bloat the API for the colDef quite a bit if we consider every edge case as a property!

from mui-x.

achoud444 avatar achoud444 commented on July 22, 2024

@MBilalShafi @michelengelen Sorry If I am not able to explain clearly. But If you can see in this example, The action field is fine because I want to do action in company level but if you can see the createdAt field is also same for the movies so I also want them to come in the same row as action and however it is blank

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.