syncfusion-react-dropdownlist
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSyncfusion React DropDownList
Syncfusion React 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 - 值绑定:预选择值、绑定原始类型与复杂对象
- 使用禁用单个选项
fields.disabled
Filtering
过滤功能
📄 Read: references/filtering.md
- Enabling for search-as-you-type
allowFiltering - Handling the event with
filteringupdateData - Filter types: ,
startswith, case-sensitive optionscontains - Remote/server-side filtering
- Minimum search length ()
minLength - Highlight filtered text, custom search logic
📄 阅读: references/filtering.md
- 启用实现输入时搜索
allowFiltering - 使用处理
updateData事件filtering - 过滤类型:、
startswith、大小写敏感选项contains - 远程/服务器端过滤
- 最小搜索长度()
minLength - 高亮过滤文本、自定义搜索逻辑
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
- CSS class customization
- Localization (,
L10n,noRecordsTemplate)actionFailureTemplate
📄 阅读: references/accessibility-styling-localization.md
- 符合WCAG 2.2 / Section 508标准
- 键盘导航快捷键
- ARIA角色与属性
- CSS类自定义
- 本地化(、
L10n、noRecordsTemplate)actionFailureTemplate
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
快速入门示例
tsx
// 1. Install
// npm install @syncfusion/ej2-react-dropdowns --save
// 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"
/>
);
}tsx
// 1. 安装
// npm install @syncfusion/ej2-react-dropdowns --save
// 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) {
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) {
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大型数据集(10000+条) → 启用并注入;请阅读。
enableVirtualizationVirtualScrollreferences/features-and-configuration.md依赖下拉菜单 → 在第一个下拉菜单的事件中重新加载第二个下拉菜单的;请阅读。
changedataSourcereferences/how-to.md