PickList is used to reorder items between different lists.
import { PickListModule } from 'primeng/picklist';
PickList is used as a controlled input with source and target properties. Content of a list item needs to be defined with the pTemplate property that receives an object in the list as parameter. Drag & drop functionality depends on @angular/cdk package.
<p-pickList
[source]="sourceProducts"
[target]="targetProducts"
sourceHeader="Available"
targetHeader="Selected"
[dragdrop]="true"
[responsive]="true"
[sourceStyle]="{ height: '30rem' }"
[targetStyle]="{ height: '30rem' }"
breakpoint="1400px">
<ng-template let-product pTemplate="item">
<div class="flex flex-wrap p-2 align-items-center gap-3">
<img
class="w-4rem shadow-2 flex-shrink-0 border-round"
src="https://primefaces.org/cdn/primeng/images/demo/product/{{ product.image }}"
alt="{item.name}" />
<div class="flex-1 flex flex-column gap-2">
<span class="font-bold">{{ product.name }}</span>
<div class="flex align-items-center gap-2">
<i class="pi pi-tag text-sm"></i>
<span>
{{ product.category }}
</span>
</div>
</div>
<span class="font-bold text-900">
{{ '$' + product.price }}
</span>
</div>
</ng-template>
</p-pickList>
Filter value is checked against the property of an object configured with the filterBy property.
<p-pickList
[source]="sourceProducts"
[target]="targetProducts"
sourceHeader="Available"
targetHeader="Selected"
[dragdrop]="true"
[responsive]="true"
[sourceStyle]="{ height: '30rem' }"
[targetStyle]="{ height: '30rem' }"
filterBy="name"
sourceFilterPlaceholder="Search by name"
targetFilterPlaceholder="Search by name"
breakpoint="1400px">
<ng-template let-product pTemplate="item">
<div class="flex flex-wrap p-2 align-items-center gap-3">
<img
class="w-4rem shadow-2 flex-shrink-0 border-round"
src="https://primefaces.org/cdn/primeng/images/demo/product/{{ product.image }}"
alt="{item.name}" />
<div class="flex-1 flex flex-column gap-2">
<span class="font-bold">
{{ product.name }}
</span>
<div class="flex align-products-center gap-2">
<i class="pi pi-tag text-sm"></i>
<span>
{{ product.category }}
</span>
</div>
</div>
<span class="font-bold text-900">
{{ '$' + product.price }}
</span>
</div>
</ng-template>
</p-pickList>
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-picklist | Container element. |
p-picklist-source-controls | Container of source list buttons. |
p-picklist-target-controls | Container of target list buttons. |
p-picklist-buttons | Container of buttons. |
p-picklist-list | List element. |
p-picklist-item | An item in the list. |
Value to describe the source listbox and target listbox can be provided with ariaLabelledBy or ariaLabel props. The list elements has a listbox role with the aria-multiselectable attribute. Each list item has an option role with aria-selected and aria-disabled as their attributes.
Controls buttons are button elements with an aria-label that refers to the aria.moveTop, aria.moveUp, aria.moveDown, aria.moveBottom,aria.moveTo, aria.moveAllTo, aria.moveFrom and aria.moveAllFrom properties of the locale API by default, alternatively you may usemoveTopButtonProps, moveUpButtonProps, moveDownButtonProps, moveToButtonProps, moveAllToButtonProps, moveFromButtonProps, moveFromButtonProps and moveAllFromButtonProps to customize the buttons like overriding the default aria-label attributes.
<span id="lb">Options</span>
<p-pickList ariaLabelledBy="lb" />
<p-pickList ariaLabel="City" />
Key | Function |
---|---|
tab | Moves focus to the first selected option, if there is none then first option receives the focus. |
up arrow | Moves focus to the previous option. |
down arrow | Moves focus to the next option. |
enter | Toggles the selected state of the focused option. |
space | Toggles the selected state of the focused option. |
home | Moves focus to the first option. |
end | Moves focus to the last option. |
shift + down arrow | Moves focus to the next option and toggles the selection state. |
shift + up arrow | Moves focus to the previous option and toggles the selection state. |
shift + space | Selects the items between the most recently selected option and the focused option. |
control + shift + home | Selects the focused options and all the options up to the first one. |
control + shift + end | Selects the focused options and all the options down to the first one. |
control + a | Selects all options. |
Key | Function |
---|---|
enter | Executes button action. |
space | Executes button action. |
API defines helper props, events and others for the PrimeNG PickList module.
PickList is used to reorder items between different lists.
Defines the input properties of the component.
Defines emit that determine the behavior of the component based on a given condition or report the actions that the component takes.
name | parameters | description | |
---|---|---|---|
onMoveToSource | event : PickListMoveToSourceEvent | Callback to invoke when items are moved from target to source. | |
onMoveAllToSource | event : PickListMoveAllToSourceEvent | Callback to invoke when all items are moved from target to source. | |
onMoveAllToTarget | event : PickListMoveAllToTargetEvent | Callback to invoke when all items are moved from source to target. | |
onMoveToTarget | event : PickListMoveToTargetEvent | Callback to invoke when items are moved from source to target. | |
onSourceReorder | event : PickListSourceReorderEvent | Callback to invoke when items are reordered within source list. | |
onTargetReorder | event : PickListTargetReorderEvent | Callback to invoke when items are reordered within target list. | |
onSourceSelect | event : PickListSourceSelectEvent | Callback to invoke when items are selected within source list. | |
onTargetSelect | event : PickListTargetSelectEvent | Callback to invoke when items are selected within target list. | |
onSourceFilter | event : PickListSourceFilterEvent | Callback to invoke when the source list is filtered | |
onTargetFilter | event : PickListTargetFilterEvent | Callback to invoke when the target list is filtered | |
onFocus | event : Event | Callback to invoke when the list is focused | |
onBlur | event : Event | Callback to invoke when the list is blurred |
Defines the templates used by the component.
Defines the custom events used by the component's emitters.
Custom move to source event.
Custom move all to source event.
Custom move all to target event.
Custom move to target event.
Custom move source reorder event.
Custom move target reorder event.
Custom source select event.
Custom target select event.
Custom source filter event.
Custom target filter event.
Defines the custom interfaces used by the module.
Callbacks to invoke on filter.