syncfusion-angular-multi-select
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing the Syncfusion Angular MultiSelect Dropdown
实现Syncfusion Angular多选下拉组件
The MultiSelect Dropdown () allows users to select one or more values from a predefined list. It supports four visual modes (Default/Box/Delimiter/CheckBox), rich filtering, templates, grouping, remote data, virtualization, and full Angular form integration.
ejs-multiselect多选下拉组件()允许用户从预定义列表中选择一个或多个值。它支持四种展示模式(默认/Box/分隔符/CheckBox)、丰富的过滤能力、模板、分组、远程数据、虚拟化,以及完整的Angular表单集成。
ejs-multiselectComponent Overview
组件概览
| Mode | Behavior | Use When |
|---|---|---|
| Selected items shown as chips in input | Standard multi-select |
| Same as Default, explicit box display | Visual clarity needed |
| Selected items as comma-separated text | Space-constrained layouts |
| Popup shows checkboxes per item | Bulk selection workflows |
| 模式 | 行为 | 适用场景 |
|---|---|---|
| 选中项以Chip的形式展示在输入框中 | 标准多选场景 |
| 与默认模式一致,有明确的框体展示 | 需要更高视觉清晰度的场景 |
| 选中项以逗号分隔的文本展示 | 空间受限的布局 |
| 弹出层中每个选项都带复选框 | 批量选择的工作流 |
Navigation Guide
导航指南
Getting Started
入门
📄 Read: references/getting-started.md
- Installation and package setup ()
ng add - CSS imports and theme configuration
- Basic in standalone Angular component
<ejs-multiselect> - Popup height/width configuration
- Angular version notes (standalone default in Angular 19+)
📄 阅读: references/getting-started.md
- 安装与包配置()
ng add - CSS导入与主题配置
- 独立Angular组件中基础的使用
<ejs-multiselect> - 弹出层高宽配置
- Angular版本说明(Angular 19+默认使用独立组件)
Data Binding & Value Binding
数据绑定与值绑定
📄 Read: references/data-binding.md
- Local arrays (strings, numbers, objects)
- mapping:
fields,text,value,groupBy,iconCssdisabled - Remote data with DataManager (OData, Web API)
- Pre-selecting values programmatically
- Object binding with
allowObjectBinding
📄 阅读: references/data-binding.md
- 本地数组(字符串、数字、对象)
- 映射:
fields、text、value、groupBy、iconCssdisabled - 基于DataManager的远程数据(OData、Web API)
- 编程式预选中值
- 配合的对象绑定
allowObjectBinding
Selection Modes, Chips & Item Control
选择模式、Chip与选项控制
📄 Read: references/selection-modes.md
- property: Default / Box / Delimiter / CheckBox
mode - CheckBox mode: ,
CheckBoxSelection,showSelectAllmaximumSelectionLength - Chip customization via event
tagging - Custom values with
allowCustomValue - Disabling specific items: ,
fields.disableddisableItem() - and
addTagOnBlurbehaviorschangeOnBlur
📄 阅读: references/selection-modes.md
- 属性:默认 / Box / 分隔符 / CheckBox
mode - 复选框模式:、
CheckBoxSelection、showSelectAllmaximumSelectionLength - 通过事件自定义Chip
tagging - 配合使用自定义值
allowCustomValue - 禁用指定选项:、
fields.disableddisableItem() - 与
addTagOnBlur行为changeOnBlur
Filtering
过滤
📄 Read: references/filtering.md
- Enabling +
allowFilteringevent +filteringupdateData() - :
filterType,startsWith,containsendsWith - Minimum character threshold before query fires
- Remote filtering with DataManager
- Case-insensitive matching
📄 阅读: references/filtering.md
- 启用+
allowFiltering事件 +filteringupdateData() - :
filterType、startsWith、containsendsWith - 查询触发前的最小字符阈值
- 基于DataManager的远程过滤
- 大小写不敏感匹配
Templates
模板
📄 Read: references/templates.md
- — custom list item rendering with
itemTemplateng-template - — customize chip/selected value display
valueTemplate - — custom group header content
groupTemplate - /
headerTemplate— popup top/bottomfooterTemplate - /
noRecordsTemplateactionFailureTemplate
📄 阅读: references/templates.md
- — 通过
itemTemplate自定义列表项渲染ng-template - — 自定义Chip/选中值的展示
valueTemplate - — 自定义分组头部内容
groupTemplate - /
headerTemplate— 弹出层顶部/底部footerTemplate - /
noRecordsTemplateactionFailureTemplate
Grouping & Cascading
分组与级联
📄 Read: references/grouping-and-items.md
- — organize items into categories
fields.groupBy - Fixed vs inline group headers
- for group-level Select All
enableGroupCheckBox - Cascading MultiSelect: parent event → filter child data
change - Country → State → City cascade pattern
📄 阅读: references/grouping-and-items.md
- — 将选项归类到不同分类下
fields.groupBy - 固定与行内分组头部
- 分组级全选功能
enableGroupCheckBox - 级联多选:父组件事件 → 过滤子组件数据
change - 国家→省份→城市级联模式
Form Integration
表单集成
📄 Read: references/form-support.md
- Template-driven forms: ,
FormsModule, two-way bindingngModel - Reactive forms: ,
ReactiveFormsModule,FormGroupFormControl - usage and validation
formControlName - Required field and custom validator patterns
📄 阅读: references/form-support.md
- 模板驱动表单:、
FormsModule、双向绑定ngModel - 响应式表单:、
ReactiveFormsModule、FormGroupFormControl - 使用与验证
formControlName - 必填字段与自定义校验规则
Advanced Features
高级功能
📄 Read: references/advanced-features.md
- Virtualization for large datasets ()
enableVirtualization - Popup resize (, resize events)
allowResize - Icons in list items (field)
iconCss - Localization (, locale key overrides)
L10n.load() - Accessibility: WAI-ARIA, keyboard navigation, WCAG 2.2
- RTL support
📄 阅读: references/advanced-features.md
- 大数据集虚拟化()
enableVirtualization - 弹出层可调整大小(、resize事件)
allowResize - 列表项图标(字段)
iconCss - 国际化(、locale键覆写)
L10n.load() - 无障碍支持:WAI-ARIA、键盘导航、WCAG 2.2
- RTL支持
API Reference
API参考
📄 Read: references/api.md
- Complete list of all properties with types and defaults
- All public methods with signatures, parameters, and return types
- All events with argument types and usage examples
- Module injection notes ()
CheckBoxSelectionService
📄 阅读: references/api.md
- 所有属性的完整列表,包含类型与默认值
- 所有公共方法,包含签名、参数与返回类型
- 所有事件,包含参数类型与使用示例
- 模块注入说明()
CheckBoxSelectionService
Quick Start
快速开始
bash
ng add @syncfusion/ej2-angular-dropdownstypescript
// app.component.ts — Standalone Angular 19+
import { Component } from '@angular/core';
import { MultiSelectModule } from '@syncfusion/ej2-angular-dropdowns';
@Component({
standalone: true,
imports: [MultiSelectModule],
selector: 'app-root',
template: `
<ejs-multiselect
[dataSource]="skills"
[fields]="fields"
placeholder="Select skills"
[(value)]="selectedSkills"
(change)="onChange($event)">
</ejs-multiselect>
`
})
export class AppComponent {
public skills = [
{ id: 1, name: 'Angular' },
{ id: 2, name: 'React' },
{ id: 3, name: 'TypeScript' },
{ id: 4, name: 'Node.js' },
];
public fields = { text: 'name', value: 'id' };
public selectedSkills: number[] = [1, 3]; // pre-select Angular & TypeScript
onChange(args: any): void {
console.log('Selected IDs:', args.value);
}
}css
/* styles.css */
@import '@syncfusion/ej2-base/styles/material3.css';
@import '@syncfusion/ej2-buttons/styles/material3.css';
@import '@syncfusion/ej2-inputs/styles/material3.css';
@import '@syncfusion/ej2-lists/styles/material3.css';
@import '@syncfusion/ej2-popups/styles/material3.css';
@import '@syncfusion/ej2-dropdowns/styles/material3.css';
@import '@syncfusion/ej2-angular-dropdowns/styles/material3.css';bash
ng add @syncfusion/ej2-angular-dropdownstypescript
// app.component.ts — 独立组件 Angular 19+
import { Component } from '@angular/core';
import { MultiSelectModule } from '@syncfusion/ej2-angular-dropdowns';
@Component({
standalone: true,
imports: [MultiSelectModule],
selector: 'app-root',
template: `
<ejs-multiselect
[dataSource]="skills"
[fields]="fields"
placeholder="Select skills"
[(value)]="selectedSkills"
(change)="onChange($event)">
</ejs-multiselect>
`
})
export class AppComponent {
public skills = [
{ id: 1, name: 'Angular' },
{ id: 2, name: 'React' },
{ id: 3, name: 'TypeScript' },
{ id: 4, name: 'Node.js' },
];
public fields = { text: 'name', value: 'id' };
public selectedSkills: number[] = [1, 3]; // 预选中Angular与TypeScript
onChange(args: any): void {
console.log('Selected IDs:', args.value);
}
}css
/* styles.css */
@import '@syncfusion/ej2-base/styles/material3.css';
@import '@syncfusion/ej2-buttons/styles/material3.css';
@import '@syncfusion/ej2-inputs/styles/material3.css';
@import '@syncfusion/ej2-lists/styles/material3.css';
@import '@syncfusion/ej2-popups/styles/material3.css';
@import '@syncfusion/ej2-dropdowns/styles/material3.css';
@import '@syncfusion/ej2-angular-dropdowns/styles/material3.css';Common Patterns
常用模式
Checkbox Mode with Select All
带全选功能的复选框模式
typescript
import { MultiSelectModule, CheckBoxSelectionService } from '@syncfusion/ej2-angular-dropdowns';
@Component({
standalone: true,
imports: [MultiSelectModule],
providers: [CheckBoxSelectionService],
template: `
<ejs-multiselect
[dataSource]="items"
mode="CheckBox"
[showSelectAll]="true"
selectAllText="Select All"
unSelectAllText="Unselect All"
[maximumSelectionLength]="5">
</ejs-multiselect>
`
})typescript
import { MultiSelectModule, CheckBoxSelectionService } from '@syncfusion/ej2-angular-dropdowns';
@Component({
standalone: true,
imports: [MultiSelectModule],
providers: [CheckBoxSelectionService],
template: `
<ejs-multiselect
[dataSource]="items"
mode="CheckBox"
[showSelectAll]="true"
selectAllText="Select All"
unSelectAllText="Unselect All"
[maximumSelectionLength]="5">
</ejs-multiselect>
`
})Filtering with Remote Data
远程数据过滤
typescript
template: `
<ejs-multiselect
[dataSource]="data"
[allowFiltering]="true"
filterType="contains"
(filtering)="onFilter($event)">
</ejs-multiselect>
`
onFilter(args: FilteringEventArgs): void {
const query = new Query().where('name', 'contains', args.text, true);
args.updateData(this.data, query);
}typescript
template: `
<ejs-multiselect
[dataSource]="data"
[allowFiltering]="true"
filterType="contains"
(filtering)="onFilter($event)">
</ejs-multiselect>
`
onFilter(args: FilteringEventArgs): void {
const query = new Query().where('name', 'contains', args.text, true);
args.updateData(this.data, query);
}Reactive Form Integration
响应式表单集成
typescript
import { ReactiveFormsModule, FormControl } from '@angular/forms';
// In component:
public skillsControl = new FormControl([1, 3]); // pre-selected IDs
// In template:
// <ejs-multiselect [formControl]="skillsControl" [dataSource]="skills" [fields]="fields">
// </ejs-multiselect>typescript
import { ReactiveFormsModule, FormControl } from '@angular/forms';
// 组件内代码:
public skillsControl = new FormControl([1, 3]); // 预选中ID
// 模板内代码:
// <ejs-multiselect [formControl]="skillsControl" [dataSource]="skills" [fields]="fields">
// </ejs-multiselect>Key Props
核心属性
| Property | Type | Purpose |
|---|---|---|
| | Items to display |
| | Maps |
| | Currently selected values (use |
| | |
| | Enables search within the dropdown |
| | |
| | Shows Select All in CheckBox mode |
| | Caps the number of selectable items |
| | Lets users add values not in the list |
| | Optimizes rendering for large lists |
| | Constrains popup dimensions |
| | Lets users drag-resize the popup |
| | Input hint text |
| 属性 | 类型 | 用途 |
|---|---|---|
| | 要展示的选项列表 |
| | 映射 |
| | 当前选中的值(使用 |
| | 可选值: |
| | 启用下拉框内搜索 |
| | 可选值: |
| | 在复选框模式下展示全选按钮 |
| | 限制可选中选项的最大数量 |
| | 允许用户添加不在列表中的值 |
| | 优化大数据列表的渲染性能 |
| | 限制弹出层的尺寸 |
| | 允许用户拖拽调整弹出层大小 |
| | 输入框提示文本 |