-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Tree view not loading server side data correctly #14241
Comments
Hey @daviesgeek ...
const dataSetOptions = {
dataSet: 'Employee' as const,
rowLength: 1000,
treeData: { maxDepth: 3, groupingField: 'name', averageChildren: 5 },
};
...
getGroupKey: (row) => row[dataSetOptions.treeData.groupingField]
|
@michelengelen thanks for your response. I did see this in the docs example, I'm still pretty unclear about what the key exactly should be, since Two questions that should hopefully clear this up: What is the definition of the grouping key? Should it be the key of what the row supposed to be grouped under, i.e., a "parent" field? Or is it supposed to be the key that defines the group of the current row, i.e., this row group and it's children are keyed off the group key? Put slightly differently, if I have data like this:
For the row "two", what is the Secondly (which may be answered by the first, but just to clarify), what is the top level grouping key supposed to be? In the example above, what is the grouping key for "one"? |
Hey @daviesgeek ... maybe From your question, consider this example:
Does that make it more clear? |
Yes that makes it clear. I did try doing this earlier both in my application and in the sandbox. If you look at this updated sandbox, you can see I set the |
@MBilalShafi could you take a look? |
Hey @daviesgeek, As @michelengelen mentioned, the Each tree data request has a In the beginning (the first call that fetches the root rows), the value of {
rows: [
{ name: 'Alice', age: 15, childrenCount: 5 },
{ name: 'Adam', age: 20, childrenCount: 2 },
{ name: 'Elizabeth', age: 25, childrenCount: 0 },
],
rowCount: 3, // Always the root level row count
} Now the Data Grid doesn't have children's information at this point, it relies on the developer to let it know:
Now, the So, in the above example, when the user clicks on the row Important In every response of the Based on the above information, I made some changes in your codesandbox example to make it work, here's the updated version: https://codesandbox.io/p/sandbox/data-grid-tree-view-forked-7y8j7x A summary of the changes
Let me know if it solves your concerns or if you have further questions. Thank you! |
@MBilalShafi this makes a lot of sense, thanks for the example. I was able to track down my issue in my code. When I use Thank you both for your help @MBilalShafi @michelengelen |
@daviesgeek: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
Steps to reproduce
Link to live example: https://codesandbox.io/p/sandbox/data-grid-tree-view-8yddmw
Steps:
All I've done to reproduce this issue is fork the sandbox on the React Server-side tree data page and attempt to integrate in my own dataset.
Current behavior
First of all, the rows are not closing, but the open/collapse arrows are moving as expected.
Secondly, the newly loaded data is loading at the bottom of the grid, not where it's supposed to be inserted.
Expected behavior
I would expect that rows that are opened can be closed, collapsing the data that it just loaded.
I would also expect, just like the demo, that rows would be inserted directly below the row that was just opened.
Context
I am just trying to get our custom dataset hooked up to the data grid tree view. I am assuming I have something wrong in the grouping key but there's little to no information about what that key is actually supposed to be.
Your environment
npx @mui/envinfo
Search keywords: data grid, tree view, server side data
Order ID: 87473
The text was updated successfully, but these errors were encountered: