0

How can I bind a Boolean column to a checkbox in ngx-datatable? Currently I am using angular material table and use the following method :

  <ng-container matColumnDef="Active">
    <mat-header-cell *matHeaderCellDef class="generic-centeredCell"> Active </mat-header-cell>
    <mat-cell *matCellDef="let element" class="generic-centeredCell">
      <span class="mobile-label">Active:</span>
      <mat-checkbox [(ngModel)]="element.active"></mat-checkbox>
    </mat-cell>
  </ng-container>

How can I make use of above code when I move to ngx-datatable? I cant event find a sample. The only samples I have seen so far is http://swimlane.github.io/ngx-datatable/#chkbox-selection which doesn't explain how to bind the boolean column to a checkbox.

1 Answer 1

3

I found the answer to my own question and I thought it might help someone in future. Above code would translate to something similar to below :

  <ngx-datatable-column name="Active">
    <ng-template ngx-datatable-cell-template let-value="value">
      <mat-checkbox [(ngModel)]="value"></mat-checkbox>
    </ng-template>
  </ngx-datatable-column>

Simply just put the control inside

using this method not only allows you to have Boolean column bound to checkbox, you can also embed other controls inside the column.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.