How to add a Multi Select Filter on a column without a "field" ?

UI Components for Angular
Post Reply
TheParadoX
Posts: 8
Joined: 11 Jul 2017, 15:52

21 Jul 2017, 09:43

Hello,

This is my Datatable:

Code: Select all

<p-dataTable emptyMessage="Keine Benutzer gefunden" [value]="users" dataKey="id" [loading]="loading" [rows]="15" [paginator]="true"
  [pageLinks]="3" [globalFilter]="gb" #dt>  

  <!-- This column works fine, it has a "field" --> 
  <p-column field="state" [filter]="true" filterMatchMode="in">
    <ng-template pTemplate="filter" let-col>
      <p-multiSelect [options]="status" defaultLabel="Status" (onChange)="dt.filter($event.value,col.field,col.filterMatchMode)"
        styleClass="ui-column-filter"></p-multiSelect>
    </ng-template>
  </p-column>

  <!-- This column does not have a "field", but I would like the same multiselect filter as the previous column. --> 
  <p-column header="Rolle" sortable="true" [filter]="true" filterMatchMode="in">
    <ng-template let-col let-user="rowData" pTemplate="body">
      <div *ngFor="let role of user.roles">
        <p>{{role.role}}</p>
      </div>
    </ng-template>
  </p-column> 

</p-dataTable>
I tried adding the following to my column:

Code: Select all

     <ng-template pTemplate="filter" let-col>
      <p-multiSelect [options]="roles" defaultLabel="Rollen" (onChange)="dt.filter($event.value,col.field,col.filterMatchMode)"
        styleClass="ui-column-filter"></p-multiSelect>
    </ng-template> 
But the filtering did not work - I feel like having two ng-template tags in a column is wrong. I am not sure what ng-template does, nor what pTemplate is (and what values it accepts - I could not find any documentation)

How can I achieve this ?

Cheers

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 62 guests