可以通过在中设置[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组件在设置了selection属性和p-tableRadioButton后怎么让控制table在选中时某些列无法选中

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

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