-
Notifications
You must be signed in to change notification settings - Fork 24
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
RenderComponent - ViewCell Interface Too Restrictive #65
Comments
One of the goals is to remove That said, the custom renderer stuff is way more fucked up as you might think. Because the truth is, that the renderer receives the object returned by the This is because typescript is not type-safe. You can actually assign arbitrary objects to So you can - without regrets - just implement your renderer like this // assume your row data looks like this
export class MyComplexObject {
attr: MyComplexAttribute;
// ...
}
export class MyComplexAttribute {
fullName: string;
// ...
}
export class MyRenderComponent implements OnInit, ViewCell {
// @ts-ignore
@Input() value: MyComplexAttribute | string;
@Input() rowData!: MyComplexObject;
data!: MyComplexAttribute;
ngOnInit(): void {
this.data = this.value as MyComplexAttribute;
this.value = this.data.fullName; // for example - but you don't need this,
// you can directly use the stuff in the HTML template The default settings = {
// ...
columns: {
// ...
attr: {
// ...
valuePrepareFunction: (value, row, cell) => value
}
}
} The same does not only work with Of course it would be nice to have a decent type for Currently the correct type would be Changing that in a reasonable way is not so easy. I keep this ticket open as a reminder and tag it with enhancement. |
Excellent, thank you for taking the time to do that writeup. It makes a lot of sense. |
Maybe somehow remotely related with #115 which suffers from similar type confusion problems. But maybe there the possibility for a non-breaking small step cleanup for v2.9.0. |
Unfortunately, any sort of type change would be likely a (minor) breaking change for the users who already use the strict typing. Will reconsider this for the next major update 3.0.0. |
Actually, we can get rid of the |
I'm not sure if there's a specific reason for it to be this way, but the
ViewCell
interface only allowsstring | number
, but I have a complex object in my data. Ultimately, I'd like to be able to have a RenderComponent that is able to dothis.renderedValue = this.value.fullName
. It seems as easy as changing theViewCell.value
property toany
. Is there a reason not to make this change?The text was updated successfully, but these errors were encountered: