【问题标题】:PrimeNG Header TemplatePrimeNG 标题模板
【发布时间】:2019-01-01 14:11:58
【问题描述】:

我正在尝试使用 PrimeNG 4.30 版向列标题添加带有工具提示的跨度。

根据this issue,应该在模板元素中使用 pTemplate 装饰器来完成(后来不赞成使用 ng-template)。 type="body" 模板工作得很好,但是当我尝试将它与 type="header" 一起使用时,标题只是空的,尽管行被填充得很好。

<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>

更改模板的顺序会使表格用我打算放在标题上的labelspan 填充行,这让我怀疑它不仅忽略了type,而且完全忽略了第一个模板。

【问题讨论】:

    标签: angular primeng primeng-datatable


    【解决方案1】:

    显然 type 属性不是正确的做法,相反,您应该直接将 pTemplate 设置为您要使用的类型。像这样:

    <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>
    

    这解决了问题。

    【讨论】:

      猜你喜欢
      • 2018-05-05
      • 2017-04-05
      • 1970-01-01
      • 1970-01-01
      • 2016-06-28
      • 1970-01-01
      • 2017-10-21
      • 2010-10-16
      • 1970-01-01
      相关资源
      最近更新 更多