How to use p-checkbox in a p-column of a p-dataTable?

UI Components for Angular
Post Reply
lne
Posts: 48
Joined: 30 Mar 2017, 08:47

14 Nov 2017, 17:32

Hi,

How to use p-checkbox in a p-column of a p-dataTable?

I try this but my checkbox is already unchecked...

Code: Select all

<p-column field="SMR" [style]="{'width':'60px'}" styleClass="col-button">
                    <ng-template let-col let-consult="rowData" pTemplate="body">
                      <p-checkbox  value="consult[col.field]"></p-checkbox>
                    </ng-template>
                  </p-column>

ctran2428
Posts: 41
Joined: 27 Apr 2017, 04:15

14 Nov 2017, 20:45

You might want to use Angular's property binding syntax which is `[]` so:

Code: Select all

<p-column field="SMR" [style]="{'width':'60px'}" styleClass="col-button">
                    <ng-template let-col let-consult="rowData" pTemplate="body">
                      <p-checkbox  [value]="consult[col.field]"></p-checkbox>
                    </ng-template>
                  </p-column>

lne
Posts: 48
Joined: 30 Mar 2017, 08:47

15 Nov 2017, 09:14

not work :-(
checkbox already unchecked

lne
Posts: 48
Joined: 30 Mar 2017, 08:47

15 Nov 2017, 09:22

I found the solution, this work:

Code: Select all

<p-column field="SMR" [style]="{'width':'60px'}" styleClass="col-button">
                    <ng-template let-col let-consult="rowData" pTemplate="body">
                        <p-checkbox [(ngModel)]="consult[col.field]" value="Y"></p-checkbox>
                    </ng-template>
                  </p-column>

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 17 guests