syncfusion-react-dropdowns
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing Syncfusion React Dropdowns
实现Syncfusion React下拉组件
AutoComplete
AutoComplete组件
The AutoComplete component provides a matched suggestion list as the user types into an input field, allowing selection from the filtered results. It supports local and remote data, rich filtering options, templates, grouping, virtualization, and full accessibility.
AutoComplete组件会在用户输入内容时显示匹配的建议列表,用户可从筛选后的结果中进行选择。它支持本地和远程数据、丰富的筛选选项、模板、分组、虚拟化以及完整的无障碍功能。
Documentation and Navigation Guide
文档与导航指南
Getting Started
快速入门
📄 Read: references/getting-started.md
- Package installation ()
@syncfusion/ej2-react-dropdowns - CSS imports and theme configuration
- Basic component setup (functional and class components)
- Binding a simple string array
- Configuring popup height and width (,
popupHeight)popupWidth
📄 阅读: references/getting-started.md
- 包安装()
@syncfusion/ej2-react-dropdowns - CSS导入与主题配置
- 基础组件设置(函数式与类组件)
- 绑定简单字符串数组
- 配置弹窗高度与宽度(、
popupHeight)popupWidth
Data Binding
数据绑定
📄 Read: references/data-binding.md
- Array of strings or numbers
- Array of objects with mapping (
fields,value,groupBy)iconCss - Array of complex/nested objects (dot-notation field mapping)
- Remote data with (ODataV4Adaptor, WebApiAdaptor)
DataManager - Using property to filter/select remote data
query - for alphabetical ordering
sortOrder
📄 阅读: references/data-binding.md
- 字符串或数字数组
- 带映射的对象数组(
fields、value、groupBy)iconCss - 复杂/嵌套对象数组(点符号字段映射)
- 使用的远程数据(ODataV4Adaptor、WebApiAdaptor)
DataManager - 使用属性筛选/选择远程数据
query - 用于字母排序的
sortOrder
Filtering
筛选
📄 Read: references/filtering.md
- Filter types: ,
StartsWith,EndsWithContains - – limit number of suggestions
suggestionCount - – minimum characters before search triggers
minLength - – case-sensitive filtering
ignoreCase - – diacritics filtering
ignoreAccent - – delay filtering to reduce requests
debounceDelay - Custom filtering with the event
filtering
📄 阅读: references/filtering.md
- 筛选类型:、
StartsWith、EndsWithContains - – 限制建议数量
suggestionCount - – 触发搜索的最小字符数
minLength - – 区分大小写的筛选
ignoreCase - – 带变音符号的筛选
ignoreAccent - – 延迟筛选以减少请求
debounceDelay - 使用事件进行自定义筛选
filtering
Grouping
分组
📄 Read: references/grouping.md
- Grouping items using
fields.groupBy - Fixed and inline group headers
- Custom group header with
groupTemplate
📄 阅读: references/grouping.md
- 使用对项目进行分组
fields.groupBy - 固定和内联分组标题
- 使用自定义分组标题
groupTemplate
Templates
模板
📄 Read: references/templates.md
- – customize each list item
itemTemplate - – customize group header
groupTemplate - – static popup header
headerTemplate - – static popup footer
footerTemplate - – message when no data found
noRecordsTemplate - – message on remote fetch failure
actionFailureTemplate
📄 阅读: references/templates.md
- – 自定义每个列表项
itemTemplate - – 自定义分组标题
groupTemplate - – 静态弹窗头部
headerTemplate - – 静态弹窗底部
footerTemplate - – 无数据时的提示信息
noRecordsTemplate - – 远程数据获取失败时的提示信息
actionFailureTemplate
Value Binding
值绑定
📄 Read: references/value-binding.md
- Binding primitive values (string, number)
- Object binding with
allowObjectBinding - Presetting selected values with the property
value
📄 阅读: references/value-binding.md
- 绑定原始值(字符串、数字)
- 使用绑定对象
allowObjectBinding - 使用属性预设选中值
value
Virtualization
虚拟化
📄 Read: references/virtual-scroll.md
- for large datasets
enableVirtualization - Injecting the service
VirtualScroll - Virtual scrolling with local data, remote data, and grouping
- Customizing item count with
query.take()
📄 阅读: references/virtual-scroll.md
- 针对大型数据集启用
enableVirtualization - 注入服务
VirtualScroll - 本地数据、远程数据和分组场景下的虚拟滚动
- 使用自定义项目数量
query.take()
Disabled Items
禁用项
📄 Read: references/disabled-items.md
- Disabling items via
fields.disabled - method for dynamic disabling
disableItem - Disabling the entire component with
enabled={false}
📄 阅读: references/disabled-items.md
- 通过禁用项
fields.disabled - 使用方法动态禁用
disableItem - 使用禁用整个组件
enabled={false}
Accessibility and Localization
无障碍与本地化
📄 Read: references/accessibility-localization.md
- WAI-ARIA roles and attributes
- Keyboard navigation shortcuts
- RTL support ()
enableRtl - Localization with (noRecordsTemplate, actionFailureTemplate text)
L10n - WCAG 2.2 compliance overview
📄 阅读: references/accessibility-localization.md
- WAI-ARIA角色与属性
- 键盘导航快捷键
- RTL支持()
enableRtl - 使用进行本地化(noRecordsTemplate、actionFailureTemplate文本)
L10n - WCAG 2.2合规概述
Styling and Customization
样式与自定义
📄 Read: references/styling.md
- CSS class targets for wrapper, icon, focus, placeholder, selection
- Float label customization
- Popup item appearance
- property for custom class injection
cssClass - Popup resize ()
allowResize - Mandatory asterisk styling
📄 阅读: references/styling.md
- 包装器、图标、焦点、占位符、选中状态的CSS类目标
- 浮动标签自定义
- 弹窗项外观
- 用于注入自定义类的属性
cssClass - 弹窗调整大小()
allowResize - 必填星号样式
How-To: Autofill, Highlight, and Icons
操作指南:自动填充、高亮与图标
📄 Read: references/how-to.md
- – suggest first matched item on Arrow Down
autofill - – highlight typed characters in suggestion list
highlight - Icon support with
fields.iconCss
📄 阅读: references/how-to.md
- – 按下向下箭头时建议第一个匹配项
autofill - – 在建议列表中高亮输入的字符
highlight - 使用支持图标
fields.iconCss
API Reference
API参考
📄 Read: references/api.md
- All properties with types, defaults, and descriptions
- All methods with parameters and return types
- All events with descriptions
📄 阅读: references/api.md
- 所有属性的类型、默认值与描述
- 所有方法的参数与返回类型
- 所有事件的描述
Quick Start Example
快速入门示例
Installation: Pin packages to a specific major version to reduce supply-chain risk.bashnpm install @syncfusion/ej2-react-dropdowns@^33.x.x @syncfusion/ej2-react-inputs@^33.x.x @syncfusion/ej2-base@^33.x.x
tsx
import { AutoCompleteComponent } from '@syncfusion/ej2-react-dropdowns'; // ^33.x.x
import '@syncfusion/ej2-base/styles/tailwind3.css';
import '@syncfusion/ej2-react-inputs/styles/tailwind3.css';
import '@syncfusion/ej2-react-dropdowns/styles/tailwind3.css';
const sportsData: string[] = [
'Badminton', 'Basketball', 'Cricket', 'Football',
'Golf', 'Hockey', 'Rugby', 'Snooker', 'Tennis'
];
export default function App() {
return (
<AutoCompleteComponent
id="sports-ac"
dataSource={sportsData}
placeholder="Find a game"
/>
);
}安装: 将包固定到特定主版本以降低供应链风险。bashnpm install @syncfusion/ej2-react-dropdowns@^33.x.x @syncfusion/ej2-react-inputs@^33.x.x @syncfusion/ej2-base@^33.x.x
tsx
import { AutoCompleteComponent } from '@syncfusion/ej2-react-dropdowns'; // ^33.x.x
import '@syncfusion/ej2-base/styles/tailwind3.css';
import '@syncfusion/ej2-react-inputs/styles/tailwind3.css';
import '@syncfusion/ej2-react-dropdowns/styles/tailwind3.css';
const sportsData: string[] = [
'Badminton', 'Basketball', 'Cricket', 'Football',
'Golf', 'Hockey', 'Rugby', 'Snooker', 'Tennis'
];
export default function App() {
return (
<AutoCompleteComponent
id="sports-ac"
dataSource={sportsData}
placeholder="Find a game"
/>
);
}Common Patterns
常见模式
Object data source with field mapping
带字段映射的对象数据源
tsx
const sportsData = [
{ id: 'Game1', game: 'Badminton' },
{ id: 'Game2', game: 'Basketball' },
];
const fields = { value: 'game' };
<AutoCompleteComponent dataSource={sportsData} fields={fields} placeholder="Find a game" />tsx
const sportsData = [
{ id: 'Game1', game: 'Badminton' },
{ id: 'Game2', game: 'Basketball' },
];
const fields = { value: 'game' };
<AutoCompleteComponent dataSource={sportsData} fields={fields} placeholder="Find a game" />Remote data binding (security-first)
远程数据绑定(安全优先)
Security: Do not call arbitrary third-party URLs directly from client code. Route external API calls through a trusted server-side proxy that enforces allowed endpoints, authentication, rate limits, and response validation.
tsx
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
// Use a controlled server proxy endpoint here. Do not use public third-party URLs directly.
const customerData = new DataManager({
adaptor: new ODataV4Adaptor(),
crossDomain: true,
url: 'https://your-trusted-proxy.example/api/customers'
});
const query = new Query().from('Customers').select(['ContactName', 'CustomerID']).take(6);
const fields = { value: 'ContactName' };
<AutoCompleteComponent
dataSource={customerData}
query={query}
fields={fields}
sortOrder="Ascending"
placeholder="Find a customer" />安全提示: 不要直接从客户端代码调用任意第三方URL。通过受信任的服务器端代理路由外部API调用,该代理应强制执行允许的端点、身份验证、速率限制和响应验证。
tsx
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
// 此处使用受控服务器代理端点。不要直接使用公共第三方URL。
const customerData = new DataManager({
adaptor: new ODataV4Adaptor(),
crossDomain: true,
url: 'https://your-trusted-proxy.example/api/customers'
});
const query = new Query().from('Customers').select(['ContactName', 'CustomerID']).take(6);
const fields = { value: 'ContactName' };
<AutoCompleteComponent
dataSource={customerData}
query={query}
fields={fields}
sortOrder="Ascending"
placeholder="Find a customer" />Filtering with custom options
带自定义选项的筛选
tsx
<AutoCompleteComponent
dataSource={sportsData}
filterType="StartsWith"
minLength={2}
suggestionCount={5}
debounceDelay={300}
ignoreCase={true}
placeholder="Type to search"
/>tsx
<AutoCompleteComponent
dataSource={sportsData}
filterType="StartsWith"
minLength={2}
suggestionCount={5}
debounceDelay={300}
ignoreCase={true}
placeholder="Type to search"
/>Accessing methods via ref
通过ref访问方法
tsx
import { AutoCompleteComponent } from '@syncfusion/ej2-react-dropdowns';
import { useRef } from 'react';
export default function App() {
const acRef = useRef<AutoCompleteComponent>(null);
return (
<>
<AutoCompleteComponent ref={acRef} dataSource={sportsData} placeholder="Find a game" />
<button onClick={() => acRef.current?.showPopup()}>Open</button>
<button onClick={() => acRef.current?.clear()}>Clear</button>
</>
);
}tsx
import { AutoCompleteComponent } from '@syncfusion/ej2-react-dropdowns';
import { useRef } from 'react';
export default function App() {
const acRef = useRef<AutoCompleteComponent>(null);
return (
<>
<AutoCompleteComponent ref={acRef} dataSource={sportsData} placeholder="Find a game" />
<button onClick={() => acRef.current?.showPopup()}>Open</button>
<button onClick={() => acRef.current?.clear()}>Clear</button>
</>
);
}ComboBox
ComboBox组件
The ComboBox component provides a dropdown input that allows users to type to filter or select from a predefined list. It supports local and remote data binding, custom values, filtering, grouping, templates, virtual scrolling, and full accessibility.
ComboBox组件提供了一个下拉输入框,允许用户通过输入进行筛选或从预定义列表中选择。它支持本地和远程数据绑定、自定义值、筛选、分组、模板、虚拟滚动以及完整的无障碍功能。
Component Overview
组件概述
The ComboBox is a specialized dropdown input that bridges typed input fields with selection lists. Key characteristics:
- Hybrid input: User can type to filter OR select from dropdown
- Smart filtering: Default filter searches by text, customizable for complex scenarios
- Flexible data: Supports strings, JSON objects, OData, Web APIs, DataManager
- Rich UI: Templates for items, headers, footers, selected values, no-results states
- Performance: Virtual scrolling efficiently handles thousands of items
- Global ready: Built-in localization, RTL support, ARIA attributes
- Accessible: Full keyboard navigation, screen reader support
Installation: Pin packages to a specific major version to reduce supply-chain risk.bashnpm install @syncfusion/ej2-react-dropdowns@^33.x.x
ComboBox是一个专门的下拉输入框,它将输入字段与选择列表结合起来。主要特点:
- 混合输入: 用户可以输入内容进行筛选,也可以从下拉列表中选择
- 智能筛选: 默认筛选按文本搜索,可针对复杂场景进行自定义
- 灵活的数据支持: 支持字符串、JSON对象、OData、Web API、DataManager
- 丰富的UI: 项、头部、底部、选中值、无结果状态的模板
- 高性能: 虚拟滚动可高效处理数千条数据
- 全球化支持: 内置本地化、RTL支持、ARIA属性
- 无障碍: 完整的键盘导航、屏幕阅读器支持
安装: 将包固定到特定主版本以降低供应链风险。bashnpm install @syncfusion/ej2-react-dropdowns@^33.x.x
Documentation Navigation Guide
文档导航指南
Choose your starting point based on your task:
根据你的任务选择起点:
Getting Started
快速入门
📄 Read: references/getting-started.md
When to read:
- Setting up ComboBox in a new project
- First-time component implementation
- Understanding basic usage (class vs functional components)
- Adding CSS imports and themes
- Enabling custom values
📄 阅读: references/getting-started.md
适用场景:
- 在新项目中设置ComboBox
- 首次实现组件
- 了解基本用法(类组件vs函数式组件)
- 添加CSS导入与主题
- 启用自定义值
Data Binding & Sources
数据绑定与数据源
📄 Read: references/data-binding.md
When to read:
- Binding local data (string arrays, JSON objects)
- Connecting to remote APIs (OData, Web API, DataManager)
- Mapping object fields (text, value, groupBy, iconCss)
- Handling complex data transformations
- Understanding data source configuration
📄 阅读: references/data-binding.md
适用场景:
- 绑定本地数据(字符串数组、JSON对象)
- 连接到远程API(OData、Web API、DataManager)
- 映射对象字段(text、value、groupBy、iconCss)
- 处理复杂数据转换
- 了解数据源配置
Filtering & Search Behavior
筛选与搜索行为
📄 Read: references/filtering-and-search.md
When to read:
- Implementing text filtering
- Creating custom filter functions
- Configuring search behavior (case sensitivity, partial matching)
- Performance optimization for large datasets
- Handling no-results scenarios
📄 阅读: references/filtering-and-search.md
适用场景:
- 实现文本筛选
- 创建自定义筛选函数
- 配置搜索行为(大小写敏感、部分匹配)
- 大型数据集的性能优化
- 处理无结果场景
Grouping & Sorting
分组与排序
📄 Read: references/grouping-and-sorting.md
When to read:
- Organizing items into logical groups
- Customizing group header appearance
- Applying sort orders (ascending/descending)
- Combining grouping with filtering
- Multi-level grouping scenarios
📄 阅读: references/grouping-and-sorting.md
适用场景:
- 将项组织为逻辑组
- 自定义分组标题外观
- 应用排序顺序(升序/降序)
- 结合分组与筛选
- 多级分组场景
Templates & Customization
模板与自定义
📄 Read: references/templates-and-customization.md
When to read:
- Creating custom item templates
- Displaying rich content (images, icons, descriptions)
- Header/footer templates (e.g., action buttons, summaries)
- Selected value template formatting
- CSS class-based styling and theme customization
📄 阅读: references/templates-and-customization.md
适用场景:
- 创建自定义项模板
- 显示丰富内容(图片、图标、描述)
- 头部/底部模板(如操作按钮、摘要)
- 选中值模板格式化
- 基于CSS类的样式与主题自定义
Advanced Features
高级功能
📄 Read: references/advanced-features.md
When to read:
- Virtual scrolling for large datasets (10,000+ items)
- Internationalization (i18n) and language switching
- RTL (right-to-left) support for Arabic/Hebrew
- Accessibility compliance (WCAG 2.1, ARIA attributes)
- Disabled states and multi-select workflows
- Keyboard shortcuts and focus management
📄 阅读: references/advanced-features.md
适用场景:
- 大型数据集的虚拟滚动(10,000+条数据)
- 国际化(i18n)与语言切换
- 阿拉伯语/希伯来语的RTL(从右到左)支持
- 无障碍合规性(WCAG 2.1、ARIA属性)
- 禁用状态与多选工作流
- 键盘快捷键与焦点管理
Styling & Theming
样式与主题
📄 Read: references/styling-and-theming.md
When to read:
- Applying built-in Syncfusion themes (Material, Bootstrap, Tailwind)
- CSS variable customization for brand colors
- Theme Studio integration for design customization
- Responsive design patterns
- Dark mode / light mode support
📄 阅读: references/styling-and-theming.md
适用场景:
- 应用内置Syncfusion主题(Material、Bootstrap、Tailwind)
- 自定义CSS变量以匹配品牌颜色
- Theme Studio集成以进行设计自定义
- 响应式设计模式
- 深色/浅色模式支持
Popup Resizing
弹窗调整大小
📄 Read: references/popup-resizing.md
When to read:
- Allowing users to dynamically resize the dropdown
- Saving resize preferences across sessions
- Handling long content with custom templates
- Mobile-friendly dropdown sizing
📄 阅读: references/popup-resizing.md
适用场景:
- 允许用户动态调整下拉框大小
- 在会话间保存调整大小的偏好
- 使用自定义模板处理长内容
- 移动端友好的下拉框尺寸
How-To Guide
操作指南
📄 Read: references/how-to-guide.md
When to read:
- Implementing autofill (auto-complete while typing)
- Creating cascading/dependent dropdowns (Country → State → City)
- Displaying icons in list items
- Common practical implementation scenarios
📄 阅读: references/how-to-guide.md
适用场景:
- 实现自动填充(输入时自动完成)
- 创建级联/依赖下拉框(国家→州→城市)
- 在列表项中显示图标
- 常见的实际实现场景
Troubleshooting
故障排除
📄 Read: references/troubleshooting.md
When to read:
- Performance issues (slow rendering, lag)
- Data binding problems
- Migration from EJ1 ComboBox
- Common edge cases and workarounds
- Debugging tips and community resources
📄 阅读: references/troubleshooting.md
适用场景:
- 性能问题(渲染缓慢、延迟)
- 数据绑定问题
- 从EJ1 ComboBox迁移
- 常见边缘情况与解决方法
- 调试技巧与社区资源
API Reference
API参考
📄 Read: references/api.md
When to read:
- Looking up a specific property, method, or event name and its type
- Understanding default values for any configuration option
- Checking event argument shapes (,
ChangeEventArgs, etc.)FilteringEventArgs - Reviewing all available methods for programmatic control
- Exploring interface models (,
FieldSettingsModel, etc.)PopupEventArgs
📄 阅读: references/api.md
适用场景:
- 查询特定属性、方法或事件名称及其类型
- 了解任何配置选项的默认值
- 检查事件参数的结构(、
ChangeEventArgs等)FilteringEventArgs - 查看所有可用的程序化控制方法
- 探索接口模型(、
FieldSettingsModel等)PopupEventArgs
Quick Start Example
快速入门示例
Installation & Setup
安装与设置
Installation: Pin packages to a specific major version to reduce supply-chain risk.bashnpm install @syncfusion/ej2-react-dropdowns@^33.x.x
安装: 将包固定到特定主版本以降低供应链风险。bashnpm install @syncfusion/ej2-react-dropdowns@^33.x.x
Basic ComboBox (Functional Component)
基础ComboBox(函数式组件)
tsx
import { ComboBoxComponent } from '@syncfusion/ej2-react-dropdowns';
import '@syncfusion/ej2-base/styles/tailwind3.css';
import '@syncfusion/ej2-react-dropdowns/styles/tailwind3.css';
export default function App() {
const sportsList = ['Badminton', 'Cricket', 'Football', 'Golf', 'Tennis'];
return (
<ComboBoxComponent
id="combobox"
dataSource={sportsList}
placeholder="Select a sport"
allowCustom={true}
/>
);
}tsx
import { ComboBoxComponent } from '@syncfusion/ej2-react-dropdowns';
import '@syncfusion/ej2-base/styles/tailwind3.css';
import '@syncfusion/ej2-react-dropdowns/styles/tailwind3.css';
export default function App() {
const sportsList = ['Badminton', 'Cricket', 'Football', 'Golf', 'Tennis'];
return (
<ComboBoxComponent
id="combobox"
dataSource={sportsList}
placeholder="Select a sport"
allowCustom={true}
/>
);
}With Data Binding (JSON Objects)
带数据绑定(JSON对象)
tsx
export default function App() {
const sportsData = [
{ Id: 'game1', Game: 'Badminton', Players: 2 },
{ Id: 'game2', Game: 'Football', Players: 11 },
{ Id: 'game3', Game: 'Cricket', Players: 11 }
];
const fields = { text: 'Game', value: 'Id' };
return (
<ComboBoxComponent
id="combobox"
dataSource={sportsData}
fields={fields}
placeholder="Select a game"
change={(e) => console.log('Selected:', e.value)}
/>
);
}tsx
export default function App() {
const sportsData = [
{ Id: 'game1', Game: 'Badminton', Players: 2 },
{ Id: 'game2', Game: 'Football', Players: 11 },
{ Id: 'game3', Game: 'Cricket', Players: 11 }
];
const fields = { text: 'Game', value: 'Id' };
return (
<ComboBoxComponent
id="combobox"
dataSource={sportsData}
fields={fields}
placeholder="Select a game"
change={(e) => console.log('Selected:', e.value)}
/>
);
}Common Patterns
常见模式
Pattern 1: Filtered Search for User Selection
模式1:用于用户选择的筛选搜索
Problem: User needs to find items in a list of 500+ entries.
Solution: Use filtering with controlled input to display only matching items. For very large datasets (5,000+ items), combine with and inject .
Solution: Use filtering with controlled input to display only matching items. For very large datasets (5,000+ items), combine with
enableVirtualizationVirtualScrolltsx
import { ComboBoxComponent, Inject, VirtualScroll } from '@syncfusion/ej2-react-dropdowns';
const [filterValue, setFilterValue] = useState('');
<ComboBoxComponent
dataSource={largeDataset}
fields={{ text: 'name', value: 'id' }}
filtering={(e) => filterByName(e, 'name')}
change={(e) => setFilterValue(e.value)}
allowFiltering={true}
enableVirtualization={true}
popupHeight="200px"
>
<Inject services={[VirtualScroll]} />
</ComboBoxComponent>问题: 用户需要在500+条条目的列表中查找项。
解决方案: 使用带受控输入的筛选来仅显示匹配项。对于非常大的数据集(5,000+条数据),结合并注入。
解决方案: 使用带受控输入的筛选来仅显示匹配项。对于非常大的数据集(5,000+条数据),结合
enableVirtualizationVirtualScrolltsx
import { ComboBoxComponent, Inject, VirtualScroll } from '@syncfusion/ej2-react-dropdowns';
const [filterValue, setFilterValue] = useState('');
<ComboBoxComponent
dataSource={largeDataset}
fields={{ text: 'name', value: 'id' }}
filtering={(e) => filterByName(e, 'name')}
change={(e) => setFilterValue(e.value)}
allowFiltering={true}
enableVirtualization={true}
popupHeight="200px"
>
<Inject services={[VirtualScroll]} />
</ComboBoxComponent>Pattern 2: Grouped Categories
模式2:分组类别
Problem: Items need to be organized by type for clarity.
Solution: Use groupBy field mapping with data grouped by category.
Solution: Use groupBy field mapping with data grouped by category.
tsx
const categorizedData = [
{ Category: 'Sports', Item: 'Cricket', value: 1 },
{ Category: 'Sports', Item: 'Football', value: 2 },
{ Category: 'Games', Item: 'Chess', value: 3 },
{ Category: 'Games', Item: 'Carrom', value: 4 }
];
const fields = {
text: 'Item',
value: 'value',
groupBy: 'Category'
};
<ComboBoxComponent dataSource={categorizedData} fields={fields} />问题: 需要按类型组织项以提高清晰度。
解决方案: 使用groupBy字段映射按类别分组的数据。
解决方案: 使用groupBy字段映射按类别分组的数据。
tsx
const categorizedData = [
{ Category: 'Sports', Item: 'Cricket', value: 1 },
{ Category: 'Sports', Item: 'Football', value: 2 },
{ Category: 'Games', Item: 'Chess', value: 3 },
{ Category: 'Games', Item: 'Carrom', value: 4 }
];
const fields = {
text: 'Item',
value: 'value',
groupBy: 'Category'
};
<ComboBoxComponent dataSource={categorizedData} fields={fields} />Pattern 3: Remote Data with Loading (security-first)
模式3:带加载状态的远程数据(安全优先)
Problem: Fetch data from an API based on user search.
Security-first solution: Route external API requests through a trusted server-side proxy that validates and sanitizes responses. Do not embed third‑party URLs directly in client-side code.
tsx
import { DataManager, WebApiAdaptor } from '@syncfusion/ej2-data';
// Use your server-side proxy here. The proxy should enforce allowed upstream hosts and
// sanitize responses before returning to the client.
const dataManager = new DataManager({
url: 'https://your-trusted-proxy.example/api/search',
adaptor: new WebApiAdaptor()
});
<ComboBoxComponent
dataSource={dataManager}
fields={{ text: 'name', value: 'id' }}
allowFiltering={true} />问题: 根据用户搜索从API获取数据。
安全优先解决方案: 通过受信任的服务器端代理路由外部API请求,该代理应验证并清理响应。不要在客户端代码中直接嵌入第三方URL。
tsx
import { DataManager, WebApiAdaptor } from '@syncfusion/ej2-data';
// 此处使用你的服务器端代理。代理应强制执行允许的上游主机,并在返回给客户端之前清理响应。
const dataManager = new DataManager({
url: 'https://your-trusted-proxy.example/api/search',
adaptor: new WebApiAdaptor()
});
<ComboBoxComponent
dataSource={dataManager}
fields={{ text: 'name', value: 'id' }}
allowFiltering={true} />Pattern 4: Custom Template for Rich Content
模式4:用于丰富内容的自定义模板
Problem: Display icons or additional info with each item.
Solution: Use itemTemplate prop for custom HTML rendering.
Solution: Use itemTemplate prop for custom HTML rendering.
tsx
const itemTemplate = (props) => {
return (
<div className="flex items-center gap-2">
<span className={`icon icon-${props.value}`}></span>
<span>{props.name}</span>
<small className="text-gray-500">({props.players} players)</small>
</div>
);
};
<ComboBoxComponent
dataSource={sportsData}
itemTemplate={itemTemplate}
fields={{ text: 'name', value: 'id' }}
/>问题: 在每个项中显示图标或附加信息。
解决方案: 使用itemTemplate属性进行自定义HTML渲染。
解决方案: 使用itemTemplate属性进行自定义HTML渲染。
tsx
const itemTemplate = (props) => {
return (
<div className="flex items-center gap-2">
<span className={`icon icon-${props.value}`}></span>
<span>{props.name}</span>
<small className="text-gray-500">({props.players} players)</small>
</div>
);
};
<ComboBoxComponent
dataSource={sportsData}
itemTemplate={itemTemplate}
fields={{ text: 'name', value: 'id' }}
/>Key Props Reference
关键属性参考
| Prop | Type | Description | Common Use |
|---|---|---|---|
| Array|DataManager | Data items to display | All use cases |
| FieldSettingsModel | Map data fields (text, value, groupBy, iconCss, disabled) | Complex data |
| string | Hint text when empty | UX guidance |
| boolean | Allow user to enter custom values not in the list. Default: | Open-ended input |
| boolean | Enable filter bar (search box) in the popup. Default: | Search capability |
| boolean | Enable virtual scrolling for large datasets. Requires | Large datasets (5,000+ items) |
| SortOrder | | Sorted lists |
| string|number | Dropdown height (e.g., | Layout control |
| string|number | Dropdown width (e.g., | Layout control |
| boolean | Enable/disable component. Default: | Conditional rendering |
| boolean | Prevent user input. Default: | View-only mode |
| boolean | Show clear (×) button. Default: | Allow clearing selection |
| EmitType<ChangeEventArgs> | Fires when selection changes | Event handling |
| EmitType<FilteringEventArgs> | Fires when user types; use for custom filter logic | Advanced search |
| Function|string | Custom item HTML for each list item | Rich UI |
| 属性 | 类型 | 描述 | 常见用途 |
|---|---|---|---|
| Array|DataManager | 要显示的数据项 | 所有使用场景 |
| FieldSettingsModel | 映射数据字段(text、value、groupBy、iconCss、disabled) | 复杂数据 |
| string | 为空时的提示文本 | 用户体验引导 |
| boolean | 允许用户输入列表中不存在的自定义值。默认值: | 开放式输入 |
| boolean | 在弹窗中启用筛选栏(搜索框)。默认值: | 搜索功能 |
| boolean | 为大型数据集启用虚拟滚动。需要 | 大型数据集(5,000+条数据) |
| SortOrder | | 已排序列表 |
| string|number | 下拉框高度(例如 | 布局控制 |
| string|number | 下拉框宽度(例如 | 布局控制 |
| boolean | 启用/禁用组件。默认值: | 条件渲染 |
| boolean | 阻止用户输入。默认值: | 仅查看模式 |
| boolean | 显示清除(×)按钮。默认值: | 允许清除选择 |
| EmitType<ChangeEventArgs> | 选择更改时触发 | 事件处理 |
| EmitType<FilteringEventArgs> | 用户输入时触发;用于自定义筛选逻辑 | 高级搜索 |
| Function|string | 每个列表项的自定义HTML | 丰富UI |
Next Steps
下一步
- New to ComboBox? → Start with getting-started.md
- Need specific data? → Go to data-binding.md
- Performance concerns? → Check advanced-features.md
- Design customization? → See styling-and-theming.md
- Common scenarios? → Explore how-to-guide.md (autofill, cascading, icons)
- Resizable dropdowns? → Read popup-resizing.md
- Stuck? → Visit troubleshooting.md
- Need full API details? → See api.md for all properties, methods, events, and interface models
- 首次使用ComboBox? → 从getting-started.md开始
- 需要特定数据? → 前往data-binding.md
- 性能问题? → 查看advanced-features.md
- 设计自定义? → 参考styling-and-theming.md
- 常见场景? → 探索how-to-guide.md(自动填充、级联、图标)
- 可调整大小的下拉框? → 阅读popup-resizing.md
- 遇到问题? → 访问troubleshooting.md
- 需要完整API详情? → 查看api.md获取所有属性、方法、事件和接口模型
DropDownList
DropDownList组件
The DropDownList component provides a list of predefined values from which users can select a single value. It supports local and remote data binding, filtering, grouping, custom templates, virtual scrolling, accessibility, and rich customization.
DropDownList组件提供预定义值列表,用户可从中选择单个值。它支持本地和远程数据绑定、筛选、分组、自定义模板、虚拟滚动、无障碍以及丰富的自定义功能。
Navigation Guide
导航指南
Getting Started
快速入门
📄 Read: references/getting-started.md
- Installation and package setup ()
@syncfusion/ej2-react-dropdowns - CSS imports with tailwind3 theme
- Basic DropDownList (functional and class components)
- Binding a data source
- Configuring popup height and width
📄 阅读: references/getting-started.md
- 安装与包设置()
@syncfusion/ej2-react-dropdowns - 带tailwind3主题的CSS导入
- 基础DropDownList(函数式与类组件)
- 绑定数据源
- 配置弹窗高度与宽度
Data Binding & Value Binding
数据绑定与值绑定
📄 Read: references/data-binding.md
- Binding primitive arrays (strings, numbers)
- Binding JSON object arrays with mapping (
fields,text,value,groupBy)iconCss - Remote data with (OData, ODataV4, WebAPI adaptors)
DataManager - Value binding: preselecting values, binding primitive vs. complex objects
- Disabling individual items with
fields.disabled
📄 阅读: references/data-binding.md
- 绑定原始数组(字符串、数字)
- 带映射的JSON对象数组(
fields、text、value、groupBy)iconCss - 使用的远程数据(OData、ODataV4、WebAPI适配器)
DataManager - 值绑定:预选值、绑定原始值vs复杂对象
- 通过禁用单个项
fields.disabled
Filtering
筛选
📄 Read: references/filtering.md
- Enabling for search-as-you-type
allowFiltering - Handling the event with
filteringupdateData - Preventing default filtering — always set in custom handlers
args.preventDefaultAction = true - Filter types: ,
startswith,contains, case-sensitive optionsendsWith - Filtering by multiple fields — use with
Predicateto match typed text against both.or()andtextfields (or any combination)value - Remote/server-side filtering with minimum character guard
- Diacritics filtering (), debounce delay
ignoreAccent - Highlight filtered text, custom search logic
📄 阅读: references/filtering.md
- 启用实现输入即搜索
allowFiltering - 使用处理
updateData事件filtering - 阻止默认筛选 — 在自定义处理程序中始终设置
args.preventDefaultAction = true - 筛选类型:、
startswith、contains、大小写敏感选项endsWith - 多字段筛选 — 使用和
Predicate将输入文本与.or()和text字段(或任意组合)匹配value - 带最小字符限制的远程/服务器端筛选
- 变音符号筛选()、防抖延迟
ignoreAccent - 高亮筛选文本、自定义搜索逻辑
Grouping & Templates
分组与模板
📄 Read: references/grouping-and-templates.md
- Grouping items with the field
groupBy - Fixed and inline group headers
- Custom group header template
- Item template, value (selected) template
- Header and footer templates
- No-records and action-failure templates
📄 阅读: references/grouping-and-templates.md
- 使用字段对项进行分组
groupBy - 固定和内联分组标题
- 自定义分组标题模板
- 项模板、值(选中)模板
- 头部和底部模板
- 无记录和操作失败模板
Features & Configuration
功能与配置
📄 Read: references/features-and-configuration.md
- Sorting (: ascending, descending)
sortOrder - Virtual scrolling for large lists ()
enableVirtualization - Popup resize ()
allowResize - Incremental search, clear button, readonly, disabled
- RTL support, Preact usage
📄 阅读: references/features-and-configuration.md
- 排序(:升序、降序)
sortOrder - 大型列表的虚拟滚动()
enableVirtualization - 弹窗调整大小()
allowResize - 增量搜索、清除按钮、只读、禁用
- RTL支持、Preact使用
Accessibility, Styling & Localization
无障碍、样式与本地化
📄 Read: references/accessibility-styling-localization.md
- WCAG 2.2 / Section 508 compliance
- Keyboard navigation shortcuts
- ARIA roles and attributes
- prop — scoped per-instance CSS class, multiple classes, conditional classes, built-in utility classes (
cssClass,e-error)e-success - CSS class customization (wrapper, icon, popup, list items, placeholder)
- Theming (tailwind3, material3, bootstrap5, fluent2)
- Localization (,
L10n,noRecordsTemplate)actionFailureTemplate - RTL layout ()
enableRtl
📄 阅读: references/accessibility-styling-localization.md
- WCAG 2.2 / Section 508合规性
- 键盘导航快捷键
- ARIA角色与属性
- 属性 — 每个实例的作用域CSS类、多个类、条件类、内置工具类(
cssClass、e-error)e-success - CSS类自定义(包装器、图标、弹窗、列表项、占位符)
- 主题(tailwind3、material3、bootstrap5、fluent2)
- 本地化(、
L10n、noRecordsTemplate)actionFailureTemplate - RTL布局()
enableRtl
API Reference
API参考
📄 Read: references/api.md
- Complete properties reference with types, defaults, and usage examples
- All methods with signatures, parameters, and return types
- All events with argument interfaces and usage examples
- Interface details: ,
FieldSettingsModel,ChangeEventArgs,SelectEventArgs,PopupEventArgsFilteringEventArgs - Quick-reference summary tables for properties, methods, and events
📄 阅读: references/api.md
- 完整的属性参考,包含类型、默认值和使用示例
- 所有方法的签名、参数和返回类型
- 所有事件的参数接口和使用示例
- 接口详情:、
FieldSettingsModel、ChangeEventArgs、SelectEventArgs、PopupEventArgsFilteringEventArgs - 属性、方法和事件的快速参考摘要表
How-To Patterns
操作指南模式
📄 Read: references/how-to.md
- Add, remove, or modify items dynamically
- Cascading (dependent) dropdowns
- Multiple cascading dropdowns
- Remote data how-to
- Close popup on scroll, tooltip on items, icons in items
- Value change event, clearing selected value
📄 阅读: references/how-to.md
- 动态添加、删除或修改项
- 级联(依赖)下拉框
- 多级联下拉框
- 远程数据操作指南
- 滚动时关闭弹窗、项上的工具提示、项中的图标
- 值更改事件、清除选中值
Quick Start Example
快速入门示例
Installation: Pin packages to a specific major version to reduce supply-chain risk.bashnpm install @syncfusion/ej2-react-dropdowns@^33.x.x --save
tsx
// 1. See pinned install command above.
// 2. CSS in src/App.css
// @import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-react-dropdowns/styles/tailwind3.css";
import { DropDownListComponent } from '@syncfusion/ej2-react-dropdowns';
import './App.css';
export default function App() {
const sportsData: string[] = ['Badminton', 'Cricket', 'Football', 'Golf', 'Tennis'];
return (
<DropDownListComponent
id="ddlelement"
dataSource={sportsData}
placeholder="Select a game"
/>
);
}安装: 将包固定到特定主版本以降低供应链风险。bashnpm install @syncfusion/ej2-react-dropdowns@^33.x.x --save
tsx
// 1. 参见上面的固定版本安装命令。
// 2. src/App.css中的CSS
// @import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-react-dropdowns/styles/tailwind3.css";
import { DropDownListComponent } from '@syncfusion/ej2-react-dropdowns';
import './App.css';
export default function App() {
const sportsData: string[] = ['Badminton', 'Cricket', 'Football', 'Golf', 'Tennis'];
return (
<DropDownListComponent
id="ddlelement"
dataSource={sportsData}
placeholder="Select a game"
/>
);
}Common Patterns
常见模式
JSON Object Data with Fields Mapping
带字段映射的JSON对象数据
tsx
import { DropDownListComponent } from '@syncfusion/ej2-react-dropdowns';
export default function App() {
const countryData = [
{ Id: 'au', Country: 'Australia' },
{ Id: 'br', Country: 'Brazil' },
{ Id: 'cn', Country: 'China' },
{ Id: 'in', Country: 'India' },
];
const fields = { text: 'Country', value: 'Id' };
return (
<DropDownListComponent
dataSource={countryData}
fields={fields}
placeholder="Select a country"
/>
);
}tsx
import { DropDownListComponent } from '@syncfusion/ej2-react-dropdowns';
export default function App() {
const countryData = [
{ Id: 'au', Country: 'Australia' },
{ Id: 'br', Country: 'Brazil' },
{ Id: 'cn', Country: 'China' },
{ Id: 'in', Country: 'India' },
];
const fields = { text: 'Country', value: 'Id' };
return (
<DropDownListComponent
dataSource={countryData}
fields={fields}
placeholder="Select a country"
/>
);
}Filtering (Search-as-you-type)
筛选(输入即搜索)
tsx
import { DropDownListComponent, FilteringEventArgs } from '@syncfusion/ej2-react-dropdowns';
import { Query } from '@syncfusion/ej2-data';
export default function App() {
const searchData = [
{ Index: 's1', Country: 'Alaska' },
{ Index: 's2', Country: 'California' },
{ Index: 's3', Country: 'Florida' },
];
const fields = { text: 'Country', value: 'Index' };
function onFiltering(args: FilteringEventArgs) {
// Local example: updateData is applied against local `searchData` below.
// For remote filtering, route requests through a trusted server proxy and
// validate/sanitize responses before calling `updateData`.
args.preventDefaultAction = true; // prevent built-in filter from running alongside custom logic
let query = new Query();
query = args.text !== '' ? query.where('Country', 'startswith', args.text, true) : query;
args.updateData(searchData, query);
}
return (
<DropDownListComponent
dataSource={searchData}
fields={fields}
allowFiltering={true}
filtering={onFiltering}
placeholder="Select a country"
/>
);
}tsx
import { DropDownListComponent, FilteringEventArgs } from '@syncfusion/ej2-react-dropdowns';
import { Query } from '@syncfusion/ej2-data';
export default function App() {
const searchData = [
{ Index: 's1', Country: 'Alaska' },
{ Index: 's2', Country: 'California' },
{ Index: 's3', Country: 'Florida' },
];
const fields = { text: 'Country', value: 'Index' };
function onFiltering(args: FilteringEventArgs) {
// 本地示例:updateData应用于下面的本地`searchData`。
// 对于远程筛选,通过受信任的服务器代理路由请求,并在调用`updateData`之前验证/清理响应。
args.preventDefaultAction = true; // 阻止内置筛选与自定义逻辑同时运行
let query = new Query();
query = args.text !== '' ? query.where('Country', 'startswith', args.text, true) : query;
args.updateData(searchData, query);
}
return (
<DropDownListComponent
dataSource={searchData}
fields={fields}
allowFiltering={true}
filtering={onFiltering}
placeholder="Select a country"
/>
);
}Preselect a Value
预选值
tsx
<DropDownListComponent
dataSource={sportsData}
value="Cricket"
placeholder="Select a game"
/>tsx
<DropDownListComponent
dataSource={sportsData}
value="Cricket"
placeholder="Select a game"
/>Grouped Items
分组项
tsx
const vegetableData = [
{ Vegetable: 'Cabbage', Category: 'Leafy and Salad', Id: 'item1' },
{ Vegetable: 'Chickpea', Category: 'Beans', Id: 'item6' },
{ Vegetable: 'Garlic', Category: 'Bulb and Stem', Id: 'item9' },
];
const fields = { groupBy: 'Category', text: 'Vegetable', value: 'Id' };
<DropDownListComponent dataSource={vegetableData} fields={fields} placeholder="Select a vegetable" />tsx
const vegetableData = [
{ Vegetable: 'Cabbage', Category: 'Leafy and Salad', Id: 'item1' },
{ Vegetable: 'Chickpea', Category: 'Beans', Id: 'item6' },
{ Vegetable: 'Garlic', Category: 'Bulb and Stem', Id: 'item9' },
];
const fields = { groupBy: 'Category', text: 'Vegetable', value: 'Id' };
<DropDownListComponent dataSource={vegetableData} fields={fields} placeholder="Select a vegetable" />Key Props
关键属性
| Prop | Type | Purpose |
|---|---|---|
| | Data for the list items |
| | Maps |
| | Selected/preselected value |
| | Input placeholder text |
| | Enables search filtering |
| | Handler for custom filter logic |
| | Popup list height (default auto) |
| | Popup list width (default matches input) |
| | |
| | Virtual scroll for large data |
| | User-resizable popup |
| | Enable/disable entire component |
| | Read-only mode |
| | Shows ✕ button to clear selection |
| | Right-to-left layout |
| 属性 | 类型 | 用途 |
|---|---|---|
| | 列表项的数据 |
| | 映射 |
| | 选中/预选值 |
| | 输入占位符文本 |
| | 启用搜索筛选 |
| | 自定义筛选逻辑的处理程序 |
| | 弹窗列表高度(默认自动) |
| | 弹窗列表宽度(默认匹配输入框) |
| | |
| | 大型数据的虚拟滚动 |
| | 用户可调整大小的弹窗 |
| | 启用/禁用整个组件 |
| | 只读模式 |
| | 显示✕按钮以清除选择 |
| | 从右到左布局 |
Common Use Cases
常见使用场景
Simple static list → Pass to , done.
string[]dataSourceData from API → Use with ; read .
DataManagerWebApiAdaptorreferences/data-binding.mdSearch/filter as user types → Set , handle event; read .
allowFiltering={true}filteringreferences/filtering.mdCategorized items → Map field; read .
groupByreferences/grouping-and-templates.mdCustom item layout → Use ; read .
itemTemplatereferences/grouping-and-templates.mdLarge dataset (10k+ items) → Enable + inject ; read .
enableVirtualizationVirtualScrollreferences/features-and-configuration.mdDependent dropdowns → Reload second dropdown's on first's event; read .
dataSourcechangereferences/how-to.md简单静态列表 → 将传递给即可。
string[]dataSource来自API的数据 → 使用和;阅读。
DataManagerWebApiAdaptorreferences/data-binding.md用户输入时搜索/筛选 → 设置,处理事件;阅读。
allowFiltering={true}filteringreferences/filtering.md分类项 → 映射字段;阅读。
groupByreferences/grouping-and-templates.md自定义项布局 → 使用;阅读。
itemTemplatereferences/grouping-and-templates.md大型数据集(10k+条数据) → 启用 + 注入;阅读。
enableVirtualizationVirtualScrollreferences/features-and-configuration.md依赖下拉框 → 在第一个下拉框的事件中重新加载第二个下拉框的;阅读。
changedataSourcereferences/how-to.mdListBox
ListBox组件
The Syncfusion ListBox component displays a list of items in a scrollable container, enabling single or multiple selection. It supports local and remote data binding, drag-and-drop reordering, filtering, grouping, custom templates, dual-list transfer, and full accessibility.
Syncfusion ListBox组件在可滚动容器中显示项列表,支持单选或多选。它支持本地和远程数据绑定、拖放重新排序、筛选、分组、自定义模板、双列表传输以及完整的无障碍功能。
Documentation Guide
文档指南
Navigate to specific topics based on your implementation needs:
根据你的实现需求导航到特定主题:
Getting Started
快速入门
📄 Read: references/getting-started.md
- React app setup (Vite/Create React App)
- Installing Syncfusion packages
- CSS imports and theming
- Basic ListBox component creation
- Running the application
📄 阅读: references/getting-started.md
- React应用设置(Vite/Create React App)
- 安装Syncfusion包
- CSS导入与主题设置
- 创建基础ListBox组件
- 运行应用
Selection & Events
选择与事件
📄 Read: references/selection.md
- Single selection mode
- Multiple selection mode
- Selection events and handlers
- Programmatic selection management
- Working with selected items
📄 阅读: references/selection.md
- 单选模式
- 多选模式
- 选择事件与处理程序
- 程序化选择管理
- 处理选中项
Data Binding & Structure
数据绑定与结构
📄 Read: references/data-binding.md
- Array and object data binding
- Text and value properties
- Data source configuration
- Grouping data
- Hierarchical data structures
📄 阅读: references/data-binding.md
- 数组和对象数据绑定
- 文本和值属性
- 数据源配置
- 数据分组
- 分层数据结构
Custom Templates & Icons
自定义模板与图标
📄 Read: references/icons-and-templates.md
- Icon rendering in items
- Custom item templates
- HTML content rendering
- Template variables and syntax
- Conditional rendering
📄 阅读: references/icons-and-templates.md
- 项中的图标渲染
- 自定义项模板
- HTML内容渲染
- 模板变量与语法
- 条件渲染
Advanced Features
高级功能
📄 Read: references/features.md
- Drag and drop functionality
- Filtering and search
- Sorting and grouping
- Dual ListBox (transfer list)
- Scroller configuration
- Item enable/disable
📄 阅读: references/features.md
- 拖放功能
- 筛选与搜索
- 排序与分组
- 双ListBox(传输列表)
- 滚动器配置
- 项启用/禁用
Styling & Appearance
样式与外观
📄 Read: references/style-and-appearance.md
- CSS class customization
- Theme integration
- Styling items and groups
- Responsive design
- Custom CSS variables
📄 阅读: references/style-and-appearance.md
- CSS类自定义
- 主题集成
- 项和组的样式
- 响应式设计
- 自定义CSS变量
Accessibility
无障碍
📄 Read: references/accessibility.md
- WCAG 2.2 compliance
- Keyboard navigation
- ARIA attributes
- Screen reader support
- RTL (right-to-left) support
📄 阅读: references/accessibility.md
- WCAG 2.2合规性
- 键盘导航
- ARIA属性
- 屏幕阅读器支持
- RTL(从右到左)支持
How-To Guides
操作指南
📄 Read: references/how-to-guides.md
- Add items dynamically
- Select items programmatically
- Enable/disable items
- Filter ListBox data
- Enable scroller for long lists
- Form integration & submission
📄 阅读: references/how-to-guides.md
- 动态添加项
- 程序化选择项
- 启用/禁用项
- 筛选ListBox数据
- 为长列表启用滚动器
- 表单集成与提交
Dual ListBox (Transfer)
双ListBox(传输)
📄 Read: references/dual-list-box.md
- Two-way item transfer between lists
- Toolbar operations (move up/down, transfer)
- Permission and skill assignment patterns
- Custom styling and responsive design
- Capacity limits and validation
📄 阅读: references/dual-list-box.md
- 列表间双向项传输
- 工具栏操作(上移/下移、传输)
- 权限和技能分配模式
- 自定义样式与响应式设计
- 容量限制与验证
API Reference
API参考
📄 Read: references/api.md
- Complete list of all properties with types and defaults
- All public methods with parameter details and return types
- All events with full event argument interfaces
- Sub-interfaces: ,
SelectionSettingsModel,ToolbarSettingsModel,FieldSettingsModelSourceDestinationModel
📄 阅读: references/api.md
- 所有属性的完整列表,包含类型和默认值
- 所有公共方法的参数详情和返回类型
- 所有事件的完整事件参数接口
- 子接口:、
SelectionSettingsModel、ToolbarSettingsModel、FieldSettingsModelSourceDestinationModel
Quick Start Example
快速入门示例
Installation: Pin packages to a specific major version to reduce supply-chain risk.bashnpm install @syncfusion/ej2-react-dropdowns@^33.x.x @syncfusion/ej2-base@^33.x.x
Basic ListBox with single selection:
tsx
import { ListBoxComponent } from '@syncfusion/ej2-react-dropdowns'; // ^33.x.x
import './App.css';
function App() {
const data = [
{ text: 'JavaScript', id: '1' },
{ text: 'TypeScript', id: '2' },
{ text: 'React', id: '3' },
{ text: 'Vue', id: '4' },
{ text: 'Angular', id: '5' }
];
const handleChange = (e) => {
console.log('Selected:', e.value);
};
return (
<ListBoxComponent
dataSource={data}
fields={{ text: 'text', value: 'id' }}
selectionSettings={{ mode: 'Single' }}
change={handleChange}
/>
);
}
export default App;安装: 将包固定到特定主版本以降低供应链风险。bashnpm install @syncfusion/ej2-react-dropdowns@^33.x.x @syncfusion/ej2-base@^33.x.x
带单选的基础ListBox:
tsx
import { ListBoxComponent } from '@syncfusion/ej2-react-dropdowns'; // ^33.x.x
import './App.css';
function App() {
const data = [
{ text: 'JavaScript', id: '1' },
{ text: 'TypeScript', id: '2' },
{ text: 'React', id: '3' },
{ text: 'Vue', id: '4' },
{ text: 'Angular', id: '5' }
];
const handleChange = (e) => {
console.log('Selected:', e.value);
};
return (
<ListBoxComponent
dataSource={data}
fields={{ text: 'text', value: 'id' }}
selectionSettings={{ mode: 'Single' }}
change={handleChange}
/>
);
}
export default App;Common Patterns
常见模式
Multiple Selection
多选
tsx
<ListBoxComponent
dataSource={data}
selectionSettings={{ mode: 'Multiple' }}
/>tsx
<ListBoxComponent
dataSource={data}
selectionSettings={{ mode: 'Multiple' }}
/>Checkbox Selection
复选框选择
Requires injectingservice.CheckBoxSelection
tsx
import { ListBoxComponent, SelectionSettingsModel, Inject, CheckBoxSelection } from '@syncfusion/ej2-react-dropdowns';
const selectionSettings: SelectionSettingsModel = { showCheckbox: true };
<ListBoxComponent dataSource={data} selectionSettings={selectionSettings}>
<Inject services={[CheckBoxSelection]} />
</ListBoxComponent>需要注入服务。CheckBoxSelection
tsx
import { ListBoxComponent, SelectionSettingsModel, Inject, CheckBoxSelection } from '@syncfusion/ej2-react-dropdowns';
const selectionSettings: SelectionSettingsModel = { showCheckbox: true };
<ListBoxComponent dataSource={data} selectionSettings={selectionSettings}>
<Inject services={[CheckBoxSelection]} />
</ListBoxComponent>With Search/Filter
带搜索/筛选
tsx
<ListBoxComponent
dataSource={data}
allowFiltering={true}
filterBarPlaceholder="Search items"
/>tsx
<ListBoxComponent
dataSource={data}
allowFiltering={true}
filterBarPlaceholder="Search items"
/>Custom Item Template
自定义项模板
tsx
const itemTemplate = (props) => {
return (
<div>
<span className="icon">{props.icon}</span>
<span>{props.text}</span>
</div>
);
}
<ListBoxComponent
dataSource={data}
itemTemplate={itemTemplate}
/>tsx
const itemTemplate = (props) => {
return (
<div>
<span className="icon">{props.icon}</span>
<span>{props.text}</span>
</div>
);
}
<ListBoxComponent
dataSource={data}
itemTemplate={itemTemplate}
/>Grouping Items
分组项
tsx
<ListBoxComponent
dataSource={groupedData}
fields={{ text: 'text', groupBy: 'category' }}
/>tsx
<ListBoxComponent
dataSource={groupedData}
fields={{ text: 'text', groupBy: 'category' }}
/>Key Props & Configuration
关键属性与配置
| Prop | Purpose | Example |
|---|---|---|
| Array of items to display | |
| Maps data properties to display | |
| Defines selection mode and checkbox display. For | |
| Enables filter search box | |
| Enables item drag-drop | |
| Custom template for items | Function returning JSX |
| Enables/disables the component | |
| 属性 | 用途 | 示例 |
|---|---|---|
| 要显示的项数组 | |
| 映射数据属性以显示 | |
| 定义选择模式和复选框显示。对于 | |
| 启用筛选搜索框 | |
| 启用项拖放 | |
| 项的自定义模板 | 返回JSX的函数 |
| 启用/禁用组件 | |
Common Use Cases
常见使用场景
- Select Framework - Single selection from framework list with icons
- Multi-Select Languages - Multiple selection with search filter
- Skill Picker - Custom templates with badges and descriptions
- Drag-Drop Transfer - Dual ListBox for moving items between lists
- Grouped Categories - Organizing items by category with group headers
- Searchable Item List - Large list with filter functionality
- Accessible Menu - Full keyboard navigation and screen reader support
- 选择框架 - 带图标的框架列表单选
- 多选语言 - 带搜索筛选的多选
- 技能选择器 - 带徽章和描述的自定义模板
- 拖放传输 - 用于在列表间移动项的双ListBox
- 分组类别 - 按类别组织项并显示分组标题
- 可搜索项列表 - 带筛选功能的大型列表
- 无障碍菜单 - 完整的键盘导航和屏幕阅读器支持
Next Steps
下一步
- Start with Getting Started for initial setup
- Choose your use case (selection mode, templates, features)
- Read relevant reference for implementation details
- Copy code examples and customize for your needs
- Use Accessibility guide for WCAG compliance
Need help? Each reference file contains examples, edge cases, and troubleshooting tips.
- 从快速入门开始进行初始设置
- 选择你的使用场景(选择模式、模板、功能)
- 阅读相关参考获取实现细节
- 复制代码示例并根据需求自定义
- 使用无障碍指南确保WCAG合规
需要帮助? 每个参考文件都包含示例、边缘情况和故障排除提示。
Mention
Mention组件
The Mention Component attaches to a target editable element (e.g. a ) and displays a suggestion popup when the user types a trigger character (default ). Selecting an item inserts it inline into the editor.
<div contenteditable>@Mention组件附加到目标可编辑元素(例如),当用户输入触发字符(默认)时显示建议弹窗。选择项后会将其插入到编辑器中。
<div contenteditable>@Documentation and Navigation Guide
文档与导航指南
Getting Started
快速入门
📄 Read: references/getting-started.md
- Installation and package setup ()
@syncfusion/ej2-react-dropdowns - CSS theme imports
- Basic setup with
MentionComponentproptarget - Binding a simple data source
- Custom trigger character () and
mentionCharshowMentionChar
⚠️ Security Note: Installing npm packages (and related) must be a deliberate, user-confirmed step. Do not allow automated agents to run@syncfusion/ej2-react-dropdownswithout explicit user approval, as this introduces supply-chain risk.npm install
📄 阅读: references/getting-started.md
- 安装与包设置()
@syncfusion/ej2-react-dropdowns - CSS主题导入
- 带属性的基础
target设置MentionComponent - 绑定简单数据源
- 自定义触发字符()和
mentionCharshowMentionChar
⚠️ 安全注意: 安装npm包(及相关包)必须是用户确认的 deliberate操作。不要允许自动化代理在未经用户明确批准的情况下运行@syncfusion/ej2-react-dropdowns,因为这会带来供应链风险。npm install
Working with Data
数据处理
📄 Read: references/working-with-data.md
- Binding array of strings, JSON objects, and complex nested data
- Mapping (text, value, groupBy, iconCss)
fields - Remote data with OData V4 ()
ODataV4Adaptor - Remote data with Web API ()
WebApiAdaptor - Using to filter/select remote fields
query
📄 阅读: references/working-with-data.md
- 绑定字符串数组、JSON对象和复杂嵌套数据
- 映射(text、value、groupBy、iconCss)
fields - 使用OData V4的远程数据()
ODataV4Adaptor - 使用Web API的远程数据()
WebApiAdaptor - 使用筛选/选择远程字段
query
Filtering Data
数据筛选
📄 Read: references/filtering-data.md
- Setting minimum filter character length ()
minLength - Changing filter type: ,
Contains,StartsWithEndsWith - Allowing spaces within search text ()
allowSpaces - Customizing the suggestion count ()
suggestionCount - Debounce delay for filtering ()
debounceDelay
📄 阅读: references/filtering-data.md
- 设置最小筛选字符长度()
minLength - 更改筛选类型:、
Contains、StartsWithEndsWith - 允许搜索文本中包含空格()
allowSpaces - 自定义建议数量()
suggestionCount - 筛选的防抖延迟()
debounceDelay
Templates
模板
📄 Read: references/template.md
- Item template () for custom list rendering
itemTemplate - Display template () for selected value format
displayTemplate - No-records template ()
noRecordsTemplate - Spinner/loading template ()
spinnerTemplate - Group header template ()
groupTemplate
📄 阅读: references/template.md
- 用于自定义列表渲染的项模板()
itemTemplate - 用于选中值格式的显示模板()
displayTemplate - 无记录模板()
noRecordsTemplate - 加载中/ spinner模板()
spinnerTemplate - 分组标题模板()
groupTemplate
Customization
自定义
📄 Read: references/customization.md
- Show/hide mention character in output ()
showMentionChar - Appending suffix text after selection ()
suffixText - Configuring popup height and width (,
popupHeight)popupWidth - Custom trigger character ()
mentionChar - Leading space requirement ()
requireLeadingSpace - CSS class customization ()
cssClass - Highlight matched characters ()
highlight - Ignore accent/case in search (,
ignoreAccent)ignoreCase - Z-index for popup ()
zIndex
📄 阅读: references/customization.md
- 在输出中显示/隐藏提及字符()
showMentionChar - 选择后附加后缀文本()
suffixText - 配置弹窗高度和宽度(、
popupHeight)popupWidth - 自定义触发字符()
mentionChar - 前置空格要求()
requireLeadingSpace - CSS类自定义()
cssClass - 高亮匹配字符()
highlight - 搜索时忽略重音/大小写(、
ignoreAccent)ignoreCase - 弹窗的Z-index()
zIndex
Sorting
排序
📄 Read: references/sorting.md
- Sorting suggestion list: ,
Ascending,DescendingNone
📄 阅读: references/sorting.md
- 建议列表排序:、
Ascending、DescendingNone
Disabled Items
禁用项
📄 Read: references/disabled-items.md
- Disabling items via
fields.disabled - Dynamically disabling items with method
disableItem()
📄 阅读: references/disabled-items.md
- 通过禁用项
fields.disabled - 使用方法动态禁用项
disableItem()
Accessibility
无障碍
📄 Read: references/accessibility.md
- WAI-ARIA attributes (,
aria-selected,aria-activedescendent)aria-owns - Keyboard navigation shortcuts
- WCAG 2.2 and Section 508 compliance
- RTL support ()
enableRtl
📄 阅读: references/accessibility.md
- WAI-ARIA属性(、
aria-selected、aria-activedescendent)aria-owns - 键盘导航快捷键
- WCAG 2.2和Section 508合规性
- RTL支持()
enableRtl
Localization
本地化
📄 Read: references/localization.md
- Localizing the text via
noRecordsTemplateL10n - Setting property
locale
📄 阅读: references/localization.md
- 通过本地化
L10n文本noRecordsTemplate - 设置属性
locale
API Reference
API参考
📄 Read: references/api.md
- All properties, methods, and events
- ,
target,dataSource,fields,mentionChar,minLengthsuggestionCount - Methods: ,
addItem,disableItem,getDataByValue,getItems,showPopup,hidePopup,searchdestroy - Events: ,
select,change,filtering,beforeOpen,opened,closed,dataBound,actionBegin,actionCompleteactionFailure
📄 阅读: references/api.md
- 所有属性、方法和事件
- 、
target、dataSource、fields、mentionChar、minLengthsuggestionCount - 方法:、
addItem、disableItem、getDataByValue、getItems、showPopup、hidePopup、searchdestroy - 事件:、
select、change、filtering、beforeOpen、opened、closed、dataBound、actionBegin、actionCompleteactionFailure
Quick Start Example
快速入门示例
tsx
import { MentionComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
// CSS imports
// @import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-react-dropdowns/styles/tailwind3.css";
function App() {
const mentionTarget = '#commentBox';
const users = [
{ Name: 'Selma Rose', EmailId: 'selma@example.com' },
{ Name: 'Robert', EmailId: 'robert@example.com' },
{ Name: 'William', EmailId: 'william@example.com' },
];
const fields = { text: 'Name' };
return (
<div>
<label>Comments</label>
<div id="commentBox" placeholder="Type @ to mention a user"></div>
<MentionComponent
target={mentionTarget}
dataSource={users}
fields={fields}
/>
</div>
);
}
export default App;tsx
import { MentionComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
// CSS导入
// @import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-react-dropdowns/styles/tailwind3.css";
function App() {
const mentionTarget = '#commentBox';
const users = [
{ Name: 'Selma Rose', EmailId: 'selma@example.com' },
{ Name: 'Robert', EmailId: 'robert@example.com' },
{ Name: 'William', EmailId: 'william@example.com' },
];
const fields = { text: 'Name' };
return (
<div>
<label>Comments</label>
<div id="commentBox" placeholder="Type @ to mention a user"></div>
<MentionComponent
target={mentionTarget}
dataSource={users}
fields={fields}
/>
</div>
);
}
export default App;Common Patterns
常见模式
Custom Trigger Character
自定义触发字符
Use to trigger with instead of :
mentionChar#@tsx
<MentionComponent
target="#editor"
dataSource={tags}
mentionChar="#"
showMentionChar={true}
/>使用将触发字符改为而非:
mentionChar#@tsx
<MentionComponent
target="#editor"
dataSource={tags}
mentionChar="#"
showMentionChar={true}
/>Remote Data with Filtering (security-first)
带筛选的远程数据(安全优先)
tsx
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
// SECURITY: Do not call third-party endpoints from the browser. Use a server-side
// proxy that you control and that validates/sanitizes upstream responses.
const dataSource = new DataManager({
url: 'https://your-trusted-proxy.example/api/mentions',
adaptor: new ODataV4Adaptor(),
crossDomain: true,
});
const query = new Query().from('Customers').select(['ContactName', 'CustomerID']).take(6);
const fields = { text: 'ContactName', value: 'CustomerID' };
<MentionComponent
target="#editor"
dataSource={dataSource}
fields={fields}
query={query}
minLength={2}
popupWidth="250px" />tsx
import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
// 安全提示:不要从浏览器调用第三方端点。使用你控制的服务器端代理,该代理应验证/清理上游响应。
const dataSource = new DataManager({
url: 'https://your-trusted-proxy.example/api/mentions',
adaptor: new ODataV4Adaptor(),
crossDomain: true,
});
const query = new Query().from('Customers').select(['ContactName', 'CustomerID']).take(6);
const fields = { text: 'ContactName', value: 'CustomerID' };
<MentionComponent
target="#editor"
dataSource={dataSource}
fields={fields}
query={query}
minLength={2}
popupWidth="250px" />Handling Selection Events
处理选择事件
tsx
import { SelectEventArgs } from '@syncfusion/ej2-react-dropdowns';
function onSelect(args: SelectEventArgs) {
console.log('Selected item:', args.itemData);
console.log('Selected text:', args.text);
}
<MentionComponent
target="#editor"
dataSource={users}
fields={{ text: 'Name' }}
select={onSelect}
/>tsx
import { SelectEventArgs } from '@syncfusion/ej2-react-dropdowns';
function onSelect(args: SelectEventArgs) {
console.log('Selected item:', args.itemData);
console.log('Selected text:', args.text);
}
<MentionComponent
target="#editor"
dataSource={users}
fields={{ text: 'Name' }}
select={onSelect}
/>Popup Configuration
弹窗配置
tsx
<MentionComponent
target="#editor"
dataSource={data}
fields={{ text: 'Name' }}
popupHeight="200px"
popupWidth="300px"
suggestionCount={10}
sortOrder="Ascending"
suffixText=" "
/>tsx
<MentionComponent
target="#editor"
dataSource={data}
fields={{ text: 'Name' }}
popupHeight="200px"
popupWidth="300px"
suggestionCount={10}
sortOrder="Ascending"
suffixText=" "
/>Key Props Summary
关键属性摘要
| Prop | Type | Default | Purpose |
|---|---|---|---|
| | — | CSS selector or element for the editable area |
| | | Data for suggestions |
| | | Maps data fields |
| | | Trigger character |
| | | Prepend trigger char to inserted text |
| | | Min chars before search |
| | | Max items in popup |
| | | Filter match strategy |
| | | Allow spaces in search |
| | | Sort direction |
| | | Popup height |
| | | Popup width |
| | | Text appended after selection |
| | | Space required before trigger char |
| | | Highlight search characters |
| 属性 | 类型 | 默认值 | 用途 |
|---|---|---|---|
| | — | 可编辑区域的CSS选择器或元素 |
| | | 建议数据 |
| | | 映射数据字段 |
| | | 触发字符 |
| | | 在插入的文本前添加触发字符 |
| | | 触发搜索的最小字符数 |
| | | 弹窗中的最大项数 |
| | | 筛选匹配策略 |
| | | 允许搜索文本中包含空格 |
| | | 排序方向 |
| | | 弹窗高度 |
| | | 弹窗宽度 |
| | | 选择后附加的文本 |
| | | 触发字符前需要空格 |
| | | 高亮搜索字符 |
MultiSelect
MultiSelect组件
A comprehensive skill for implementing the MultiSelect Dropdown component — enabling users to select multiple values from a list with support for filtering, grouping, templates, checkboxes, chips, virtual scrolling, and more.
这是一份关于实现MultiSelect下拉组件的全面指南——支持用户从列表中选择多个值,具备筛选、分组、模板、复选框、标签、虚拟滚动等功能。
Component Overview
组件概述
Installation: Pin packages to a specific major version to reduce supply-chain risk.bashnpm install @syncfusion/ej2-react-dropdowns@^33.x.x @syncfusion/ej2-base@^33.x.x @syncfusion/ej2-buttons@^33.x.x @syncfusion/ej2-inputs@^33.x.x
tsx
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns'; // ^33.x.x
import '@syncfusion/ej2-react-dropdowns/styles/tailwind3.css';
// Also import base dependencies:
// @syncfusion/ej2-base/styles/tailwind3.css
// @syncfusion/ej2-buttons/styles/tailwind3.css
// @syncfusion/ej2-inputs/styles/tailwind3.cssPackage:
Main component:
Checkbox module: (inject via )
Virtual scroll module: (inject via )
@syncfusion/ej2-react-dropdownsMain component:
MultiSelectComponentCheckbox module:
CheckBoxSelection<Inject services={[CheckBoxSelection]} />Virtual scroll module:
VirtualScroll<Inject services={[VirtualScroll]} />安装: 将包固定到特定主版本以降低供应链风险。bashnpm install @syncfusion/ej2-react-dropdowns@^33.x.x @syncfusion/ej2-base@^33.x.x @syncfusion/ej2-buttons@^33.x.x @syncfusion/ej2-inputs@^33.x.x
tsx
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns'; // ^33.x.x
import '@syncfusion/ej2-react-dropdowns/styles/tailwind3.css';
// 同时导入基础依赖:
// @syncfusion/ej2-base/styles/tailwind3.css
// @syncfusion/ej2-buttons/styles/tailwind3.css
// @syncfusion/ej2-inputs/styles/tailwind3.css包:
主组件:
复选框模块:(通过注入)
虚拟滚动模块:(通过注入)
@syncfusion/ej2-react-dropdowns主组件:
MultiSelectComponent复选框模块:
CheckBoxSelection<Inject services={[CheckBoxSelection]} />虚拟滚动模块:
VirtualScroll<Inject services={[VirtualScroll]} />Quick Start Example
快速入门示例
tsx
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
export default function App() {
const sportsData = ['Badminton', 'Basketball', 'Cricket', 'Football', 'Golf', 'Tennis'];
return (
<MultiSelectComponent
id="multiselect"
dataSource={sportsData}
placeholder="Select sports"
/>
);
}With objects and field mapping:
tsx
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
export default function App() {
const sportsData = [
{ id: 'game1', sports: 'Badminton' },
{ id: 'game2', sports: 'Football' },
{ id: 'game3', sports: 'Tennis' },
];
const fields = { text: 'sports', value: 'id' };
return (
<MultiSelectComponent
id="multiselect"
dataSource={sportsData}
fields={fields}
placeholder="Select a game"
/>
);
}tsx
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
export default function App() {
const sportsData = ['Badminton', 'Basketball', 'Cricket', 'Football', 'Golf', 'Tennis'];
return (
<MultiSelectComponent
id="multiselect"
dataSource={sportsData}
placeholder="Select sports"
/>
);
}带对象和字段映射:
tsx
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import * as React from 'react';
export default function App() {
const sportsData = [
{ id: 'game1', sports: 'Badminton' },
{ id: 'game2', sports: 'Football' },
{ id: 'game3', sports: 'Tennis' },
];
const fields = { text: 'sports', value: 'id' };
return (
<MultiSelectComponent
id="multiselect"
dataSource={sportsData}
fields={fields}
placeholder="Select a game"
/>
);
}Documentation and Navigation Guide
文档与导航指南
Getting Started
快速入门
📄 Read: references/getting-started.md
- Installation and package setup (Vite / CRA)
- CSS imports and theming
- Basic MultiSelect implementation (class & functional components)
- Binding a simple data source
- Popup height/width configuration
📄 阅读: references/getting-started.md
- 安装与包设置(Vite / CRA)
- CSS导入与主题设置
- 基础MultiSelect实现(类组件&函数式组件)
- 绑定简单数据源
- 弹窗高度/宽度配置
Data Binding
数据绑定
📄 Read: references/data-binding.md
- Array of strings vs array of objects
- Field mapping (,
text,value,groupBy,iconCss)disabled - Remote data via (OData, OData V4, Web API)
DataManager - JSON/JSONP formats
- Complex data binding gotchas
📄 阅读: references/data-binding.md
- 字符串数组vs对象数组
- 字段映射(、
text、value、groupBy、iconCss)disabled - 通过的远程数据(OData、OData V4、Web API)
DataManager - JSON/JSONP格式
- 复杂数据绑定注意事项
Grouping
分组
📄 Read: references/grouping.md
- Grouping items by category with
groupBy - Inline vs fixed group headers
- Group header templates
- Ordering and multi-level grouping
📄 阅读: references/grouping.md
- 使用按类别分组项
groupBy - 内联vs固定分组标题
- 分组标题模板
- 排序和多级分组
Filtering
筛选
📄 Read: references/filtering.md
- Enabling
allowFiltering - Handling the event
filtering - Query API with conditions
where() - Filter types: startswith, contains, endswith
- Case sensitivity, multiple conditions, performance
📄 阅读: references/filtering.md
- 启用
allowFiltering - 处理事件
filtering - 带条件的Query API
where() - 筛选类型:startswith、contains、endswith
- 大小写敏感、多条件、性能
Templates
模板
📄 Read: references/templates.md
- Item templates for custom list item layouts
- Value/chip templates for selected display
- Group header templates
- Header, footer, no-records, and action-failure templates
📄 阅读: references/templates.md
- 用于自定义列表项布局的项模板
- 用于选中显示的值/标签模板
- 分组标题模板
- 头部、底部、无记录和操作失败模板
Selection Modes and Features
选择模式与功能
📄 Read: references/selection-and-features.md
- Checkbox mode (inject )
CheckBoxSelection - Chip/tag display and the event
tagging - Custom values ()
allowCustomValue - Value binding (primitive and object types)
- Disabled items via
fields.disabled - Popup resizing ()
allowResize - Virtual scrolling for large datasets (inject )
VirtualScroll
📄 阅读: references/selection-and-features.md
- 复选框模式(注入)
CheckBoxSelection - 标签/标记显示和事件
tagging - 自定义值()
allowCustomValue - 值绑定(原始值和对象类型)
- 通过禁用项
fields.disabled - 弹窗调整大小()
allowResize - 大型数据集的虚拟滚动(注入)
VirtualScroll
Accessibility, Styling, and Localization
无障碍、样式与本地化
📄 Read: references/accessibility-styling-localization.md
- WAI-ARIA attributes and keyboard shortcuts
- WCAG 2.2 / Section 508 / Screen reader support
- CSS customization (chips, wrapper, icon, delimiter)
- RTL support
- Localization with
L10n
📄 阅读: references/accessibility-styling-localization.md
- WAI-ARIA属性和键盘快捷键
- WCAG 2.2 / Section 508 / 屏幕阅读器支持
- CSS自定义(标签、包装器、图标、分隔符)
- RTL支持
- 使用进行本地化
L10n
API Reference
API参考
📄 Read: references/api.md
- Complete list of all properties with types, descriptions, and defaults
- All public methods with parameter details and return types
- All events with their argument types and trigger conditions
📄 阅读: references/api.md
- 所有属性的完整列表,包含类型、描述和默认值
- 所有公共方法的参数详情和返回类型
- 所有事件的参数类型和触发条件
Key Props Reference
关键属性参考
| Prop | Type | When to Use |
|---|---|---|
| | Always required — data to display |
| | When using object data; map |
| | Change selection display: chips ( |
| | Pre-select items on load |
| | Enable search-as-you-type filtering |
| | Let users type values not in the list |
| | Return full objects as selected values instead of primitives |
| | Use for 500+ items to improve performance |
| | Let users resize the popup |
| | Limit popup list height (default: |
| | Set popup width (default: matches input) |
| | Input placeholder text |
| 属性 | 类型 | 使用场景 |
|---|---|---|
| | 始终必填——要显示的数据 |
| | 使用对象数据时;映射 |
| | 更改选择显示:标签( |
| | 加载时预选项 |
| | 启用输入即搜索筛选 |
| | 允许用户输入列表中不存在的值 |
| | 返回完整对象作为选中值而非原始值 |
| | 用于500+条数据以提升性能 |
| | 允许用户调整弹窗大小 |
| | 限制弹窗列表高度(默认: |
| | 设置弹窗宽度(默认:匹配输入框) |
| | 输入占位符文本 |
Common Use Cases
常见使用场景
Multi-tag input (chip display):
→ Use (default). Each selection becomes a chip.
mode="Box"Checkbox multi-selection:
→ Use and inject module.
mode="CheckBox"CheckBoxSelectionSearch/filter a long list:
→ Set and handle the event for remote data.
allowFiltering={true}filteringPre-select values:
→ Pass prop as an array of value-field values: .
valuevalue={['id1', 'id2']}Group by category:
→ Add to the prop: .
groupByfieldsfields={{ text: 'name', value: 'id', groupBy: 'category' }}Large datasets (1000+ items):
→ Set and inject module.
enableVirtualization={true}VirtualScrollDisable specific options:
→ Add a boolean column to your data and map it: .
disabledfields={{ ..., disabled: 'isDisabled' }}Custom entry not in list:
→ Set ; handle event for custom actions.
allowCustomValue={true}customValueSelection多标签输入(标签显示):
→ 使用(默认)。每个选择项成为一个标签。
mode="Box"复选框多选:
→ 使用并注入模块。
mode="CheckBox"CheckBoxSelection长列表搜索/筛选:
→ 设置并为远程数据处理事件。
allowFiltering={true}filtering预选值:
→ 将属性作为值字段值的数组传递:。
valuevalue={['id1', 'id2']}按类别分组:
→ 向属性添加:。
fieldsgroupByfields={{ text: 'name', value: 'id', groupBy: 'category' }}大型数据集(1000+条数据):
→ 设置并注入模块。
enableVirtualization={true}VirtualScroll禁用特定选项:
→ 向数据添加布尔型列并映射:。
disabledfields={{ ..., disabled: 'isDisabled' }}列表中不存在的自定义输入:
→ 设置;处理事件以执行自定义操作。
allowCustomValue={true}customValueSelectionDecision Guide
决策指南
User wants multiple selections?
├── Visual chips with filter → mode="Box" (default) + allowFiltering
├── Checkbox-style list → mode="CheckBox" + Inject CheckBoxSelection
└── Comma-separated display → mode="Delimiter"
Data source type?
├── Simple strings/numbers → Pass array directly to dataSource
├── Objects → Pass array + fields={{ text, value }}
└── Remote API → Use DataManager + allowFiltering + filtering event
List is very long?
└── Yes (500+) → enableVirtualization={true} + Inject VirtualScroll
Need custom item layout?
└── Use itemTemplate, valueTemplate, groupTemplate props
Need localization?
└── Read references/accessibility-styling-localization.md用户需要多选?
├── 带筛选的可视化标签 → mode="Box"(默认) + allowFiltering
├── 复选框样式列表 → mode="CheckBox" + Inject CheckBoxSelection
└── 逗号分隔显示 → mode="Delimiter"
数据源类型?
├── 简单字符串/数字 → 直接传递数组到dataSource
├── 对象 → 传递数组 + fields={{ text, value }}
└── 远程API → 使用DataManager + allowFiltering + filtering事件
列表很长?
└── 是(500+条)→ enableVirtualization={true} + Inject VirtualScroll
需要自定义项布局?
└── 使用itemTemplate、valueTemplate、groupTemplate属性
需要本地化?
└── 阅读references/accessibility-styling-localization.mdMultiColumn ComboBox
MultiColumn ComboBox组件
The Syncfusion renders a combo box with a multi-column popup grid, enabling users to select from structured tabular data. It supports local and remote data, filtering, sorting, grouping, templates, virtualization, and full accessibility compliance.
MultiColumnComboBoxComponentPackage:
@syncfusion/ej2-react-multicolumn-comboboxSyncfusion 渲染一个带多列弹窗网格的组合框,支持用户从结构化表格数据中选择。它支持本地和远程数据、筛选、排序、分组、模板、虚拟化以及完整的无障碍合规性。
MultiColumnComboBoxComponent包:
@syncfusion/ej2-react-multicolumn-comboboxNavigation Guide
导航指南
Getting Started
快速入门
📄 Read: references/getting-started.md
- Installation and package setup
- CSS imports and theme configuration (Tailwind 3)
- Rendering the first
MultiColumnComboBoxComponent - Binding ,
dataSource, andfieldswithcolumnsColumnDirective - Configuring and
popupHeightpopupWidth - Minimal working example (functional and class components)
📄 阅读: references/getting-started.md
- 安装与包设置
- CSS导入与主题配置(Tailwind 3)
- 渲染第一个
MultiColumnComboBoxComponent - 使用绑定
ColumnDirective、dataSource和fieldscolumns - 配置和
popupHeightpopupWidth - 最小工作示例(函数式和类组件)
Columns
列
📄 Read: references/columns.md
- Defining columns with and
ColumnDirectiveColumnsDirective - ,
field,header— core column propertieswidth - for column text alignment
textAlign - for cell-level custom rendering
template - for boolean columns
displayAsCheckBox - for column CSS customization
customAttributes - for custom column headers
headerTemplate - for data formatting
format
📄 阅读: references/columns.md
- 使用和
ColumnDirective定义列ColumnsDirective - 、
field、header— 核心列属性width - 用于列文本对齐
textAlign - 用于单元格级自定义渲染
template - 用于布尔列
displayAsCheckBox - 用于列CSS自定义
customAttributes - 用于自定义列标题
headerTemplate - 用于数据格式化
format
Data Binding
数据绑定
📄 Read: references/data-binding.md
- Binding local object arrays via
dataSource - Remote data binding with and
DataManagerWebApiAdaptor - Mapping (
fields,text,value)groupBy - Using property for filtered/limited data sets
query - OData, OData V4, Web API adaptor patterns
📄 阅读: references/data-binding.md
- 通过绑定本地对象数组
dataSource - 使用和
DataManager绑定远程数据WebApiAdaptor - 映射(
fields、text、value)groupBy - 使用属性筛选/限制数据集
query - OData、OData V4、Web API适配器模式
Filtering
筛选
📄 Read: references/filtering.md
- Enabling/disabling filtering with
allowFiltering - Changing filter mode with (
filterType,StartsWith,EndsWith)Contains - event for custom filter logic
filtering - Disabling filtering for read-only scenarios
📄 阅读: references/filtering.md
- 使用启用/禁用筛选
allowFiltering - 使用更改筛选模式(
filterType、StartsWith、EndsWith)Contains - 事件用于自定义筛选逻辑
filtering - 只读场景下禁用筛选
Sorting
排序
📄 Read: references/sorting.md
- Enabling sorting with
allowSorting - Setting initial sort order with (
sortOrder,None,Ascending)Descending - Sorting multiple columns with (
sortType,OneColumn)MultipleColumns - Clicking column headers to toggle sort direction
📄 阅读: references/sorting.md
- 使用启用排序
allowSorting - 使用设置初始排序顺序(
sortOrder、None、Ascending)Descending - 使用对多列排序(
sortType、OneColumn)MultipleColumns - 点击列标题切换排序方向
Grouping
分组
📄 Read: references/grouping.md
- Grouping data with
fields.groupBy - Fixed group headers in popup
- Using to customize group headers
groupTemplate
📄 阅读: references/grouping.md
- 使用分组数据
fields.groupBy - 弹窗中的固定分组标题
- 使用自定义分组标题
groupTemplate
Templates
模板
📄 Read: references/templates.md
- for customizing each row
itemTemplate - (on
headerTemplate) for custom column headersColumnDirective - for group header customization
groupTemplate - for popup footer content
footerTemplate - for empty state display
noRecordsTemplate - for remote fetch error state
actionFailureTemplate
📄 阅读: references/templates.md
- 用于自定义每行
itemTemplate - (在
headerTemplate上)用于自定义列标题ColumnDirective - 用于分组标题自定义
groupTemplate - 用于弹窗底部内容
footerTemplate - 用于空状态显示
noRecordsTemplate - 用于远程获取错误状态
actionFailureTemplate
Items and Configuration
项与配置
📄 Read: references/items.md
- Setting initial selection with ,
text,valueindex - and
placeholderfor input label behaviorfloatLabelType - to allow clearing selection
showClearButton - and
disabledstatesreadonly - ,
width,popupWidthfor sizingpopupHeight - for custom styling
cssClass - for additional HTML attributes
htmlAttributes - for grid lines, row height, and alternate rows
gridSettings - for data constraints
query - method,
addItems,focusIn,focusOut,showPopuphidePopup
📄 阅读: references/items.md
- 使用、
text、value设置初始选择index - 和
placeholder用于输入标签行为floatLabelType - 允许清除选择
showClearButton - 和
disabled状态readonly - 、
width、popupWidth用于尺寸设置popupHeight - 用于自定义样式
cssClass - 用于附加HTML属性
htmlAttributes - 用于网格线、行高和交替行
gridSettings - 用于数据约束
query - 方法、
addItems、focusIn、focusOut、showPopuphidePopup
Virtualization
虚拟化
📄 Read: references/virtualization.md
- Enabling for large datasets
enableVirtualization - Virtual scrolling with local and remote data
- Combining with
gridSettings.rowHeight
📄 阅读: references/virtualization.md
- 为大型数据集启用
enableVirtualization - 本地和远程数据的虚拟滚动
- 与结合使用
gridSettings.rowHeight
Events
事件
📄 Read: references/events.md
- — fired when value changes or item is selected
change - — fired on item selection
select - /
open— popup open/close lifecycleclose - — fired on character input for custom filtering
filtering - /
actionBegin/actionComplete— data fetch lifecycleactionFailure
📄 阅读: references/events.md
- — 值更改或项选中时触发
change - — 项选中时触发
select - /
open— 弹窗打开/关闭生命周期close - — 用户输入字符时触发,用于自定义筛选
filtering - /
actionBegin/actionComplete— 数据获取生命周期actionFailure
API Reference
API参考
📄 Read: references/api.md
- Complete list of all properties with types and defaults
- All events with their argument types
- All methods: ,
addItems,focusIn,focusOut,getDataByValue,getItems,showPopuphidePopup - properties
ColumnModel - properties
GridSettingsModel - properties
FieldSettingsModel
📄 阅读: references/api.md
- 所有属性的完整列表,包含类型和默认值
- 所有事件的参数类型
- 所有方法:、
addItems、focusIn、focusOut、getDataByValue、getItems、showPopuphidePopup - 属性
ColumnModel - 属性
GridSettingsModel - 属性
FieldSettingsModel
Accessibility
无障碍
📄 Read: references/accessibility.md
- WCAG 2.2 and Section 508 compliance
- WAI-ARIA attributes (,
role,aria-expanded, etc.)aria-selected - Keyboard navigation shortcuts
- RTL support with
enableRtl - Screen reader support
📄 阅读: references/accessibility.md
- WCAG 2.2和Section 508合规性
- WAI-ARIA属性(、
role、aria-expanded等)aria-selected - 键盘导航快捷键
- 使用的RTL支持
enableRtl - 屏幕阅读器支持
Localization
本地化
📄 Read: references/localization.md
- Localizing text using
noRecordsTemplateL10n - Setting property for culture-specific rendering
locale - Loading translation objects
📄 阅读: references/localization.md
- 使用本地化
L10n文本noRecordsTemplate - 设置属性以实现特定文化的渲染
locale - 加载翻译对象
Quick Start
快速入门
tsx
import { MultiColumnComboBoxComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-multicolumn-combobox';
import * as React from 'react';
import './App.css';
// CSS in App.css:
// @import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-grids/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-react-multicolumn-combobox/styles/tailwind3.css";
function App() {
const empData = [
{ EmpID: 1001, Name: 'Andrew Fuller', Designation: 'Team Lead', Country: 'England' },
{ EmpID: 1002, Name: 'Robert', Designation: 'Developer', Country: 'USA' },
{ EmpID: 1003, Name: 'Michael', Designation: 'HR', Country: 'Russia' },
];
const fields = { text: 'Name', value: 'EmpID' };
return (
<MultiColumnComboBoxComponent
id="multicolumn"
dataSource={empData}
fields={fields}
placeholder="Select an employee"
>
<ColumnsDirective>
<ColumnDirective field='EmpID' header='Employee ID' width={120} />
<ColumnDirective field='Name' header='Name' width={120} />
<ColumnDirective field='Designation' header='Designation' width={120} />
<ColumnDirective field='Country' header='Country' width={100} />
</ColumnsDirective>
</MultiColumnComboBoxComponent>
);
}
export default App;tsx
import { MultiColumnComboBoxComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-multicolumn-combobox';
import * as React from 'react';
import './App.css';
// App.css中的CSS:
// @import "../node_modules/@syncfusion/ej2-base/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-inputs/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-grids/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-popups/styles/tailwind3.css";
// @import "../node_modules/@syncfusion/ej2-react-multicolumn-combobox/styles/tailwind3.css";
function App() {
const empData = [
{ EmpID: 1001, Name: 'Andrew Fuller', Designation: 'Team Lead', Country: 'England' },
{ EmpID: 1002, Name: 'Robert', Designation: 'Developer', Country: 'USA' },
{ EmpID: 1003, Name: 'Michael', Designation: 'HR', Country: 'Russia' },
];
const fields = { text: 'Name', value: 'EmpID' };
return (
<MultiColumnComboBoxComponent
id="multicolumn"
dataSource={empData}
fields={fields}
placeholder="Select an employee"
>
<ColumnsDirective>
<ColumnDirective field='EmpID' header='Employee ID' width={120} />
<ColumnDirective field='Name' header='Name' width={120} />
<ColumnDirective field='Designation' header='Designation' width={120} />
<ColumnDirective field='Country' header='Country' width={100} />
</ColumnsDirective>
</MultiColumnComboBoxComponent>
);
}
export default App;Common Patterns
常见模式
Pre-select an item by text
通过文本预选项
tsx
<MultiColumnComboBoxComponent dataSource={empData} fields={fields} text="Michael">
{/* columns */}
</MultiColumnComboBoxComponent>tsx
<MultiColumnComboBoxComponent dataSource={empData} fields={fields} text="Michael">
{/* columns */}
</MultiColumnComboBoxComponent>Enable filtering with Contains mode
启用包含模式的筛选
tsx
<MultiColumnComboBoxComponent
dataSource={empData}
fields={fields}
allowFiltering={true}
filterType="Contains"
>
{/* columns */}
</MultiColumnComboBoxComponent>tsx
<MultiColumnComboBoxComponent
dataSource={empData}
fields={fields}
allowFiltering={true}
filterType="Contains"
>
{/* columns */}
</MultiColumnComboBoxComponent>Enable sorting (descending) with multi-column support
启用(降序)排序并支持多列
tsx
import { SortOrder } from '@syncfusion/ej2-react-multicolumn-combobox';
<MultiColumnComboBoxComponent
dataSource={empData}
fields={fields}
allowSorting={true}
sortOrder={SortOrder.Descending}
sortType="MultipleColumns"
>
{/* columns */}
</MultiColumnComboBoxComponent>tsx
import { SortOrder } from '@syncfusion/ej2-react-multicolumn-combobox';
<MultiColumnComboBoxComponent
dataSource={empData}
fields={fields}
allowSorting={true}
sortOrder={SortOrder.Descending}
sortType="MultipleColumns"
>
{/* columns */}
</MultiColumnComboBoxComponent>Handle value change event
处理值更改事件
tsx
<MultiColumnComboBoxComponent
dataSource={empData}
fields={fields}
change={(args) => console.log('Selected:', args.value)}
>
{/* columns */}
</MultiColumnComboBoxComponent>tsx
<MultiColumnComboBoxComponent
dataSource={empData}
fields={fields}
change={(args) => console.log('Selected:', args.value)}
>
{/* columns */}
</MultiColumnComboBoxComponent>