1

I'm trying to add a span with a tooltip to a column header using PrimeNG version 4.30.

According to this issue, it should be done using pTemplate decorator in a template element (later deprecated in favor of ng-template). The type="body" templates works just fine, but when I try to use it with type="header" the header is just empty, despite the rows being filled just fine.

<p-column sortable="true">
 <ptemplate pTemplate type="header">
 <label>my field</label>
 <span class="fa fa-question-circle" pTooltip="my tooltip" tooltipPosition="right" tooltipEvent="hover" showDelay="50" hideDelay="200"></span>
 </ptemplate>
 <ng-template let-linha="rowData" pTemplate type="body">
 {{linha.myField}}
 </ng-template>
</p-column>

Changing the order of the templates makes the table fill the rows with the label and span I intended to put on the header, making me suspect it's ignoring not only the type but the first template altogether.

asked Jul 24, 2018 at 20:51

1 Answer 1

0

Apparently the type attribute is not the right way to do it, instead you should set the pTemplate directly with the type you want to use. Like this:

<p-column sortable="true">
 <ptemplate pTemplate="header">
 <label>my field</label>
 <span class="fa fa-question-circle" pTooltip="my tooltip" tooltipPosition="right" tooltipEvent="hover" showDelay="50" hideDelay="200"></span>
 </ptemplate>
 <ng-template let-linha="rowData" pTemplate="body">
 {{linha.myField}}
 </ng-template>
</p-column>

This solved the problem.

answered Jul 25, 2018 at 17:16
Sign up to request clarification or add additional context in comments.

1 Comment

There is no such thing as a <ptemplate> element or PrimeNG component. Both this answer and its question should be deleted as misleading.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.