-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[docs] Improve the getRowId
doc section
#5156
Conversation
These are the results for the performance tests:
|
getRowId
doc section
I'm a bit confused by this situation. Tell me if this is correct:
|
Pretty much
The "id" column, if is exists, has nothing to do with the identifier of the grid. That's a confusion José had and I think he"s not the only one at all.
Yes. I just avoid talking about "field" because it's a name tightly linked to the columns (to avoid the confusion described above).
|
Thanks for the clarification @flaviendelangle! It's starting to make more sense to me. The use cases you've described are particularly helpful. My first thought after reading the documentation as it stands was, "what if there is no unique ID in the data set to point to with Here's how I understand it now: Each row must have a unique identifier. Is that correct? As a side note—how do you feel about "unique identifier" here instead of "id" when not referring specifically to |
100% correct 👍
I think the clearer, the better |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's how I'd write this section, now that I understand how it works! 😁
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
Co-authored-by: Sam Sycamore <71297412+samuelsycamore@users.noreply.github.com>
## Row identifier | ||
|
||
Each row must have a unique identifier. | ||
|
||
This identifier is used internally to identify the row in the various models—for instance, the row selection model—and to track the row across updates. | ||
|
||
When using dataset without a unique `id` property, you can use the `getRowId` prop to specify a custom id for each row. | ||
By default, the data grid looks for a property named `id` in the data set to get that identifier. | ||
|
||
If the row's identifier is not called `id`, then you need to use the `getRowId` prop to tell the grid where it's located. | ||
|
||
The following demo shows how to use `getRowId` to grab the unique identifier from a property named `internalId`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can improve that one in #5195
I felt like it was already an improvement and could be shiped as is if needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt like it was already an improvement and could be shiped as is if needed
@flaviendelangle For sure 👍 . This is only an instance of a larger topic.
My root question is about: what should be our general practice about paragraphs and what's our threshold to split sentences into multiple paragraphs once the content cover is too further away? It's mostly a question for @samuelsycamore. We started to surface the matter in the past. I feel that our current threshold is too low, I want to advocate for the side that says: we don't group enough. Another instance was mui/material-ui#32325 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these look good to me, so I'm happy to accommodate either style. I would say that in general, I don't think paragraphs should be any longer than they are in the latter version. With dense material like this, it's easy to get lost in the middle of a paragraph.
I think this paragraph is the ideal length for text like this:
So we could say that as a general rule, you should consider a line break after 2 sentences or ~200 characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @mbrookes for perspective on the matter.
If we were to look for rules that could work in practice, I would personally imagine that above 500 characters, a paragraph is either too verbose to cover one matter and should be broken down, or it's actually covering multiple matters and hence should be broken down too. In the docs of Stripe (one I would assume receives a lot of care), it's common to find paragraphs of almost 400 characters e.g. https://stripe.com/docs/products-prices/how-products-and-prices-work but It's hard to find one above 500.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm with @oliviertassinari on this one. The second example is superior to the first. But if they needed to be to convey the concept, each paragraph could comfortably be twice as long. I don't think that there should be an arbitrary rule on paragraph length – paragraphs aren't measured in words or sentences; but I agree that verbosity should be eliminated, and that paragraphs should cover one narrow topic.
https://deploy-preview-5156--material-ui-x.netlify.app/x/react-data-grid/rows/#row-identifier
Closes #5126
Don't talk about "id field" to avoid confusion between the "id column" and the "id property in the row model".
Create a standalone section instead of putting everything in a warning
Add a warning saying that getRowId must be memoized
Should we add a note saying that the grid does not require an "id" column ?
I think it's what the
Note that [column definition](https://mui.com/x/react-data-grid/column-definition) for id field is not required.
tries to say but it's not very comprehensible in its current form.