首页 > 解决方案 > 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>

标签: angularprimeng

解决方案


只需将pessoa您想要的添加到数组pessoaSelecionado中。它应该工作。如果没有,请向我们展示您的打字稿的外观。


推荐阅读