angular - Deixar item pre selecionado no P-TableRadioButton
问题描述
我想在表格中保留预选项目,我正在使用带有单选按钮的 primeNG-Angular 表格。p-tableRadioButton。有人可以帮我解决这个问题,因为我没有找到出路。我只能生成表格,所以我可以选择。
按照代码:**
<p-table [value]="pessoa" [(selection)]="pessoaSelecionado">
<ng-template pTemplate="header" let-columns>
<tr>
<th style="width: 3em"></th>
<th>Nome</th>
<th>idade</th>
<th>Sexo</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-rowData>
<tr [pSelectableRow]="rowData.id">
<td>
<p-tableRadioButton [value]="rowData.id" ></p-tableRadioButton>
</td>
<td>{{rowData.nome}}</td>
<td>{{rowData.idade}}</td>
<td>{{rowData.sexo}}</td>
</tr>
</ng-template>
<ng-template pTemplate="summary">
<div style="text-align: left">
</div>
</ng-template>
</p-table>
解决方案
只需将pessoa
您想要的添加到数组pessoaSelecionado
中。它应该工作。如果没有,请向我们展示您的打字稿的外观。
推荐阅读
- html - 忽略子容器
- android - 如何在屏幕底部对齐视图,但也在相对布局中的其他视图下方对齐
- prolog - common_suffix/4 序言
- user-interface - 如何在空手道 UI 自动化中与复制的剪贴板内容进行交互
- python - Ursina 引擎中不存在“load_texture”功能
- sql - 来自两个表的两个最大日期时间值的 Datediff,并根据差异更新第三个表
- javascript - 如何使 Google Analytics/Pixel 脚本仅在按钮单击事件时触发
- ios - 如何在警报(.. 消息:文本)中左对齐多行消息?
- html - 悬停在图片上时如何创建圆形悬停显示
- node.js - 如何在 Nodejs 和 PostgreSql 上查询多个表?