Replies: 1 comment
-
|
Thanks for the suggestion and extensive documentation! I think this would be great addition to the docs for Are you open to submitting a PR to update the docs? I can help you through the process. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I believe we could possibly provide more detailed documentation around:
setKeypropI struggled to understand why the selection on
DetailsListdoesn't work. The problem was: I didn't assign thesetKeyprop:The only documentation available for
setKeyis:https://docs.microsoft.com/en-us/javascript/api/react/idetailslistprops?view=office-ui-fabric-react-latest#@fluentui-react-idetailslistprops-setkey-member
The same is true for Intellisense in the editor:
Even with this explanation, I was struggling to understand why I have to assign any string to it.
Since we have the
getKeymethod,setKeyseemed like a setter for the thing for which thegetKeyis getter.However, these two are not related. Rather,
setKeymeans "the key of the set", where the set is currently loaded data toDetailsList.Whenever the
setKeyis changed, grid selection is cleared. So you would probably want to update thesetKeywith each grid reload (if you don't want to keep the previous selection). Probably using a counter (of reloads), or generated GUID (upon each reload).I missed the word "items" (so it's not a single item, but many items at once - "a set"):
A key that uniquely identifies the given **items**.Furthermore, if one doesn't assign the
getKeycallback, then the default key will be "key". This variable name could sometimes exist in the retrieved data (API response), so we must use another key. And that's what thegetKeyis for.If one wants to use some variable name that won't clash (for instance
__id__), then they have to assign it to every data row:Then, the corresponding
getKeymethod should be:This method should then be used both by
Selectionobject, and byDetailsList(for using it as a key in React).Selection (custom hook):
DetailsList:
Beta Was this translation helpful? Give feedback.
All reactions