Loading...
Loading...
Implement the Syncfusion Angular ListBox component for selection and data display. Use this when building interactive list interfaces with single or multiple selection modes. This skill covers drag-and-drop functionality, grouped data display, icons and templates, filtering, and accessibility support for enterprise-grade list components in Angular applications.
npx skill4agent add syncfusion/angular-ui-components-skills syncfusion-angular-list-box| Feature | Benefit |
|---|---|
| Multiple Selection Modes | Single, multiple, or checkbox selection |
| Data Binding | Local arrays, complex objects, or remote services |
| Drag & Drop | Reorder items or transfer between lists |
| Customization | Icons, templates, grouping, sorting |
| Accessibility | WCAG 2.2, screen readers, keyboard navigation |
| Performance | Efficient rendering with large datasets |
FieldSettingsModelSelectionSettingsModelToolbarSettingsModelListBoxChangeEventArgsDragEventArgsDropEventArgsBeforeItemRenderEventArgsFilteringEventArgsSourceDestinationModelSelectionModeSortOrderFilterTypeToolBarPositionCheckBoxPositionimport { Component, OnInit } from '@angular/core';
import { ListBoxModule } from '@syncfusion/ej2-angular-dropdowns';
@Component({
imports: [ListBoxModule],
standalone: true,
selector: 'app-listbox',
template: `
<ejs-listbox
[dataSource]="items"
[selectionSettings]="{ mode: 'Multiple' }">
</ejs-listbox>
`
})
export class ListBoxComponent implements OnInit {
public items: { [key: string]: Object }[] = [];
ngOnInit(): void {
this.items = [
{ text: 'Option 1', id: '1' },
{ text: 'Option 2', id: '2' },
{ text: 'Option 3', id: '3' }
];
}
}/* In your global styles.css */
@import '@syncfusion/ej2-base/styles/material3.css';
@import '@syncfusion/ej2-dropdowns/styles/material3.css';
@import '@syncfusion/ej2-inputs/styles/material3.css';
@import '@syncfusion/ej2-lists/styles/material3.css';import { ListBoxChangeEventArgs } from '@syncfusion/ej2-dropdowns';
selectedValues: string[] = [];
onSelectionChange(args: ListBoxChangeEventArgs): void {
this.selectedValues = args.value as string[];
console.log('Selected values:', args.value);
console.log('Selected items:', args.items);
}<ejs-listbox
[dataSource]="items"
(change)="onSelectionChange($event)">
</ejs-listbox>sourceItems = [
{ text: 'Available Item 1', id: '1' },
{ text: 'Available Item 2', id: '2' }
];
selectedItems = [];<div style="display: flex; gap: 20px;">
<div>
<h4>Available Items</h4>
<ejs-listbox
[dataSource]="sourceItems"
allowDragAndDrop="true"
scope="transfer-list">
</ejs-listbox>
</div>
<div>
<h4>Selected Items</h4>
<ejs-listbox
[dataSource]="selectedItems"
allowDragAndDrop="true"
scope="transfer-list">
</ejs-listbox>
</div>
</div>allItems = [
{ text: 'Apple', category: 'Fruit' },
{ text: 'Carrot', category: 'Vegetable' },
{ text: 'Banana', category: 'Fruit' }
];
get filteredItems() {
return this.allItems.filter(item =>
item.text.toLowerCase().includes(this.searchTerm.toLowerCase())
);
}selectionSettings{ mode: 'Single' | 'Multiple', showCheckbox: boolean, showSelectAll: boolean, checkboxPosition: 'Left' | 'Right' }showCheckbox: trueCheckBoxSelectiontypescriptimport { ListBoxComponent, CheckBoxSelection, ListBoxModule } from '@syncfusion/ej2-angular-dropdowns'; ListBoxComponent.Inject(CheckBoxSelection); @Component({ imports: [ListBoxModule] }) ```- **`maximumSelectionLength`**: Limit how many items can be selected
valuestring[] | number[] | boolean[]dataSourcefields{ text, value, groupBy, iconCss, disabled, htmlAttributes }itemTemplatenoRecordsTemplateallowDragAndDropscopeallowFilteringfilterBarPlaceholderfilterType'StartsWith' | 'EndsWith' | 'Contains'toolbarSettingsheightsortOrder'None' | 'Ascending' | 'Descending'enabledenableRtlcssClass