Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Multiple columns using ngTemplateRef #1748

Closed
dlascarez opened this issue Sep 15, 2023 · 4 comments
Closed

Multiple columns using ngTemplateRef #1748

dlascarez opened this issue Sep 15, 2023 · 4 comments
Labels

Comments

@dlascarez
Copy link
Contributor

dlascarez commented Sep 15, 2023

If you have more than one column using ngTemplateRef, all columns will be overwritten with the latest one.

@ViewChild('tplIconColumn') public tplIconColumn?: TemplateRef<any>; @ViewChild('tplActionColumn') public tplActionColumn?: TemplateRef<any>;

I am assigning columns like:

ngAfterViewInit(): void { this.dtOptions.columns = [ { title: '', data: null, defaultContent: '', ngTemplateRef: { ref: this.tplIconColumn } }, { title: 'Title', data: 'title', name: 'title' }, { title: 'Description', data: 'description', name: 'description' }, { title: '', data: null, defaultContent: '', ngTemplateRef: { ref: this.tplActionColumn } }, ]; }

The final result overwrite the content of "tplIconColumn" with content from "tplActionColumn", and the column that should display the content of "tplActionColumn" is displaying empty content.

image

It must display the content like:

image
@dlascarez
Copy link
Contributor Author

dlascarez commented Sep 15, 2023

I have found the bug. In your example, you are setting data as null:
image

But data is use as filter key to select the index position to render the content.
image

At this point, all columns with data: null and implementing a template will be overwritten.

@dlascarez
Copy link
Contributor Author

Issue fixed with PR:
#1750

@miamilabs
Copy link

Any plans to release this hotfix?

@shanmukhateja
Copy link
Collaborator

@miamilabs I completely forgot to release this. Apologies.

You can find this fix in v16.0.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants