Why is `selectCheck` bound?
See original GitHub issueI’m submitting a … (check one with “x”)
[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter
Current behavior
Because selectCheck
is bound to the selection.component
it’s pretty difficult to use.
Expected behavior
selectCheck
is a documented as a pure function that takes three arguments. There’s no reason (obvious to me) that it should be bound (.bind(this)
) to anything but the component where I implement it.
What is the motivation / use case for changing the behavior?
for selectCheck
to be useful, we need access to fields in the class implementing the table.
// in our class which implements the table:
selectCheck(row) {
// compare to what? I cannot reference a field on my class here,
// because `this` maps to the `DataTableSelectionComponent` instance,
// which our code knows nothing about.
}
There are workarounds, obviously, but since selectCheck
seems to be documented as a pure function, and is passed to array.filter anyway, what is the use-case for it being bound to DataTableSelectionComponent
Please tell us about your environment:
Windows, VSCode, npm, webpack + webpackDevServer
-
Table version: 9.0.0
-
Angular version: 4.0.2
-
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] all
-
Language: [all | TypeScript X.X | ES6/7 | ES5] all
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:5
Top GitHub Comments
Still exist in ^16.1.1. For future devs:
If you need access to your component where you implemented this table, declare your function like this:
But this way you cannot call to the component functions or vars
Extracted from https://github.com/swimlane/ngx-datatable/issues/560
Is there any workaround available? I’d like to reference field from my class.