Loading...
Loading...
Compare original and translation side by side
| 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 |
| 特性 | 优势 |
|---|---|
| 多种选择模式 | 支持单选、多选或复选框选择 |
| 数据绑定 | 支持本地数组、复杂对象或远程服务 |
| 拖拽功能 | 可重排列表项或在列表间转移条目 |
| 自定义能力 | 支持图标、模板、分组、排序 |
| 无障碍适配 | 符合WCAG 2.2标准,支持屏幕阅读器、键盘导航 |
| 性能表现 | 可高效渲染大规模数据集 |
FieldSettingsModelSelectionSettingsModelToolbarSettingsModelListBoxChangeEventArgsDragEventArgsDropEventArgsBeforeItemRenderEventArgsFilteringEventArgsSourceDestinationModelSelectionModeSortOrderFilterTypeToolBarPositionCheckBoxPositionFieldSettingsModelSelectionSettingsModelToolbarSettingsModelListBoxChangeEventArgsDragEventArgsDropEventArgsBeforeItemRenderEventArgsFilteringEventArgsSourceDestinationModelSelectionModeSortOrderFilterTypeToolBarPositionCheckBoxPositionimport { 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' }
];
}
}import { 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';/* 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>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>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())
);
}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[]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`**: 限制可选中的条目上限
valuestring[] | number[] | boolean[]dataSourcefields{ text, value, groupBy, iconCss, disabled, htmlAttributes }itemTemplatenoRecordsTemplatedataSourcefields{ text, value, groupBy, iconCss, disabled, htmlAttributes }itemTemplatenoRecordsTemplateallowDragAndDropscopeallowFilteringfilterBarPlaceholderfilterType'StartsWith' | 'EndsWith' | 'Contains'toolbarSettingsallowDragAndDropscopeallowFilteringfilterBarPlaceholderfilterType'StartsWith' | 'EndsWith' | 'Contains'toolbarSettingsheightsortOrder'None' | 'Ascending' | 'Descending'enabledenableRtlcssClassheightsortOrder'None' | 'Ascending' | 'Descending'enabledenableRtlcssClass