在 Angular PrimeNG Table 组件中,通过设置 `selectionMode` 属性,可以控制某些列是否可以选中内容。例如,要让表格的第一列不可选中,可以在 `` 中设置 `selectionMode` 属性为 'none',如下所示:

<p-table [value]="data" [(selection)]="selectedItems">
  <ng-template pTemplate="header">
    <tr>
      <th style="width: 20px"></th>
      <th>Name</th>
      <th>Age</th>
    </tr>
  </ng-template>
  <ng-template pTemplate="body" let-item>
    <tr>
      <td><p-tableRadioButton [value]="item"></p-tableRadioButton></td>
      <td>{{item.name}}</td>
      <td>{{item.age}}</td>
    </tr>
  </ng-template>
  <p-tableColumn selectionMode='none'></p-tableColumn>
</p-table>

在上面的代码中,我们在 `` 中设置了 `selectionMode` 属性为 'none',这样第一列就无法选中了。

Angular PrimeNG Table 组件:控制某些列无法选中内容

原文地址: https://www.cveoy.top/t/topic/mRTr 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录