primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Table: Document possibility to pass function as dataKey

Open AndreasHae opened this issue 2 years ago • 1 comments

Describe the bug

I just spent an hour investigating our internal use of the p-table component because we are passing a function to its dataKey property, while both the documentation and the Typescript type indicate that only string values are allowed.

Both the type and the docs should indicate that it is possible to pass a function instead of the property path.

Environment

?

Reproducer

No response

Angular version

15.2.9

PrimeNG version

15.3.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

16.13.2

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

AndreasHae avatar Jun 13 '23 14:06 AndreasHae

In our use case, we are iterating over SomeEnum and then do row expansion using Map<SomeEnum, BoringDetails[]>. Sadly, it's impossible to use rowexpansion without a dataKey (expansion leads to Error: dataKey or groupRowsBy must be defined to use row expansion), yet... enum doesn't have any dataKey that could be used (however it is itself perfectly valid dataKey!).

We would happily use dataKey="identity" (assuming identity = v => v) if that was possible - currently we are forced to use dataKey="$any(identity)" and pray that the implementation doesn't change. It seems that this change would require only declared type change, as it ObjectUtils.resolveFieldData is being used under the hood.

perceptron8 avatar Apr 29 '24 07:04 perceptron8