VPP
VPP

Reputation: 779

How to Add the text "All" next to select all check box in PrimeNG multiselect

I have a PrimeNG multiselect with Select all option. Currently the "Select All" option is just rendered as a check box with no labels against it. I would like add the text "All" against the select all option.

<p-multiSelect [options]="years" [style]="{'width':'300px'}" [(ngModel)]="selectedYears"
                            [filter]="true" [showToggleAll]="true"></p-multiSelect>

enter image description here

Upvotes: 3

Views: 2267

Answers (1)

Marek Jaczewski
Marek Jaczewski

Reputation: 41

  1. You can add flag [filter]="false" to p-multiselect:
<p-multiSelect [options]="years" [style]="{'width':'300px'}" [(ngModel)]="selectedYears" [filter]="false" [showToggleAll]="true"></p-multiSelect>
  1. Put template into p-multiselect element:
<ng-template pTemplate="header">
  <div class="checkbox-all-text">{{ sharedResources.ALL }}</div>
</ng-template>
  1. add css:
.checkbox-all-text {
    position: absolute;
    left: 40px;
}

Upvotes: 4

Related Questions