DataTable: support passing a function to the dataKey prop #2589
Labels
Type: Enhancement
Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone
I'm submitting a ... (check one with "x")
This can be considered a bug report or a feature request, depending on the point of view.
CodeSandbox Case (Bug Reports)
https://codesandbox.io/s/purple-cloud-j8ehhg?file=/src/App.vue
Current behavior
The DataTable works as expected, but a warning is shown in the console:
Expected behavior
No warning.
Minimal reproduction of the problem with instructions
Instead of passing a
String
in thedataKey
property, use aFunction
.What is the motivation / use case for changing the behavior?
Sometimes a simple property is not enough for specifying the unique key of the items. For example, if you have a database table that uses a Composite PK, you will need to use 2 or more columns in order to get a unique identifier for each object.
If the
dataKey
property of the DataTable supports passing a function, the developer of the application will be able to indicate how that unique key must be generated, no matter how complex that logic is.This is actually already supported, as the
dataKey
prop is evaluated using theObjectUtils.resolveFieldData(data, field)
method, which supports passing a function in thefield
parameter. However, as the prop is declared asString
, Vue shows an annoying warning each time the component is rendered.Please tell us about your environment:
The text was updated successfully, but these errors were encountered: