Page 1 of 1

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

Posted: 14 Nov 2017, 17:32
by lne
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>

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

Posted: 14 Nov 2017, 20:45
by ctran2428
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>

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

Posted: 15 Nov 2017, 09:14
by lne
not work :-(
checkbox already unchecked

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

Posted: 15 Nov 2017, 09:22
by lne
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>