-
Notifications
You must be signed in to change notification settings - Fork 427
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
fix: GroupingGetterFunction should be allowed to return arbitrary value #957
fix: GroupingGetterFunction should be allowed to return arbitrary value #957
Conversation
I again disagree with this change, the |
We are currently trying to port our quite extensive usage of the original, slightly modified SlickGrid to this fork and this surfaced when typechecking our codebase. I guess that a) I belive relevant logic is here: https://github.com/6pac/SlickGrid/blob/508aa7b872408c9371f77267921bb053d1f7e290/src/slick.dataview.ts#L905C6-L905C6 |
both a & b are already covered by the interface type GroupingGetterFunction<T = any> = (value: T) => string;
interface Grouping<T = any> {
//
getter?: string | GroupingGetterFunction<T>; can be a string or a function returning a string
} so again, the interface seems correct as it is |
ahh actually I see what you mean, when it's a function it returns the item value directly. in that case I think SlickGrid/src/slick.dataview.ts Lines 881 to 883 in 508aa7b
|
Agreed - will change return type of function to |
Underlying slickgrid logic only takes into account equality between values returned for grouping individial rows. Getter thus does not need to return `string` but might return arbitrary value (e.g. string, number, Date).
b99b512
to
ae8cb9b
Compare
@@ -3,7 +3,7 @@ import { GroupingComparerItem } from "./groupingComparerItem.interface"; | |||
import { GroupingFormatterItem } from "./groupingFormatterItem.interface"; | |||
import { SortDirectionNumber } from "./sortDirectionNumber.enum"; | |||
|
|||
export type GroupingGetterFunction<T = any> = (value: T) => string; | |||
export type GroupingGetterFunction<T = any> = (value: T) => any; |
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.
now thinking about it and I think it should actually be returning type T
when the Generic Type is provided for the item datacontext type (which defaults to any
when not provided), it is for the value so that should be the correct type to use. Sorry for asking to change it so many time, I just realized it now 😅
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.
damn I think I'm wrong again and this is the value not the datacontext, so it could really be any
thing
This is now available in the latest release v5.7.0, thanks again for your contributions |
Thank you - for merging this and also for maintaining this great lib and making it future-proof! |
Underlying slickgrid logic only takes into account equality between values returned for grouping individial rows. Getter thus does not need to return
string
but might return arbitrary value (e.g. string, number, Date).Typing return value as
unknown
will force underlying logic using grouping getter to take into consideration that user might specify grouping function that returns arbitrary value type for individual row. With previous getter signature, user was forced to specify function that returned string, which is however not currenly needed by internal slickgrid logic.