-
Data Grid
- Overview
-
Data Binding
-
Paging and Scrolling
-
Editing
-
Grouping
-
Filtering and Sorting
- Focused Row
-
Row Drag & Drop
-
Selection
-
Columns
- State Persistence
-
Appearance
-
Templates
-
Data Summaries
-
Master-Detail
-
Export to PDF
-
Export to Excel
-
Adaptability
- Keyboard Navigation
-
Pivot Grid
- Overview
-
Data Binding
-
Field Chooser
-
Features
-
Export to Excel
-
Tree List
- Overview
-
Data Binding
- Sorting
- Paging
-
Editing
- Node Drag & Drop
- Focused Row
-
Selection
-
Filtering
-
Column Customization
- State Persistence
- Adaptability
- Keyboard Navigation
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Features
- Virtual Scrolling
-
Grouping
-
Customization
- Adaptability
-
Html Editor
-
Chat
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
Charts
- Overview
-
Data Binding
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Line Charts
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
-
Sparkline Charts
-
Tree Map
-
Funnel and Pyramid Charts
- Sankey Chart
-
Combinations
-
More Features
-
Export
-
Selection
-
Tooltips
-
Zooming
-
-
Gantt
- Overview
-
Data
-
UI Customization
- Strip Lines
- Export to PDF
- Sorting
-
Filtering
-
Gauges
- Overview
-
Data Binding
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Navigation
- Overview
- Accordion
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
- Pagination
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Box
- Responsive Box
- Resizable
-
-
Editors
- Overview
- Autocomplete
-
Calendar
- Check Box
- Color Box
-
Date Box
-
Date Range Box
-
Drop Down Box
-
Number Box
-
Select Box
- Switch
-
Tag Box
- Text Area
- Text Box
- Validation
- Custom Text Editor Buttons
- Right-to-Left Support
- Editor Appearance Variants
-
Forms and Multi-Purpose
- Overview
- Button Group
- Field Set
-
Filter Builder
-
Form
- Radio Group
-
Range Selector
- Numeric Scale (Lightweight)
- Numeric Scale
- Date-Time Scale (Lightweight)
- Date-Time Scale
- Logarithmic Scale
- Discrete scale
- Custom Formatting
- Use Range Selection for Calculation
- Use Range Selection for Filtering
- Image on Background
- Chart on Background
- Customized Chart on Background
- Chart on Background with Series Template
- Range Slider
- Slider
-
Sortable
-
File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Actions and Lists
- Overview
-
Action Sheet
-
Button
- Floating Action Button
- Drop Down Button
-
Context Menu
-
List
-
Lookup
-
Maps
- Overview
-
Map
-
Vector Map
-
Dialogs and Notifications
-
Localization
React List - List Selection
There are three List item selection modes: "single", "multiple", and "all". To enable item selection, pass the mode name to the selectionMode property. If you set this property to "none" (default setting), item selection is disabled. In this demo, you can try out all the selection modes. Use the drop-down Selection Mode menu to switch between modes.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
import React, { useCallback, useState } from 'react';
import SelectBox from 'devextreme-react/select-box';
import List, { ListTypes } from 'devextreme-react/list';
import CheckBox from 'devextreme-react/check-box';
import ArrayStore from 'devextreme/data/array_store';
import {
tasks,
selectAllModeLabel,
selectionModeLabel,
selectByClickLabel,
} from './data.ts';
const dataSource = new ArrayStore({
key: 'id',
data: tasks,
});
const selectionModes = ['none', 'single', 'multiple', 'all'];
const selectAllModes = ['page', 'allPages'];
export default function App() {
const [selectionMode, setSelectionMode] = useState<ListTypes.Properties['selectionMode']>('all');
const [selectAllMode, setSelectAllMode] = useState<ListTypes.Properties['selectAllMode']>('page');
const [selectByClick, setSelectByClick] = useState(false);
const [selectedItemKeys, setSelectedItemKeys] = useState([]);
const onSelectedItemKeysChange = useCallback(({ name, value }) => {
if (name === 'selectedItemKeys') {
if (selectionMode !== 'none' || selectedItemKeys.length !== 0) {
setSelectedItemKeys(value);
}
}
}, [selectionMode, selectedItemKeys, setSelectedItemKeys]);
const onSelectionModeChange = useCallback((value) => {
setSelectionMode(value);
}, [setSelectionMode]);
const onSelectAllModeChange = useCallback((value) => {
setSelectAllMode(value);
}, [setSelectAllMode]);
const onSelectByClickChange = useCallback((value) => {
setSelectByClick(value);
}, [setSelectByClick]);
return (
<React.Fragment>
<div className="widget-container">
<List
dataSource={dataSource}
height={400}
showSelectionControls={true}
selectionMode={selectionMode}
selectAllMode={selectAllMode}
selectedItemKeys={selectedItemKeys}
selectByClick={selectByClick}
onOptionChanged={onSelectedItemKeysChange}>
</List>
<div className="selected-data">
<span className="caption">Selected IDs: </span>
<span>{ selectedItemKeys.join(', ') }</span>
</div>
</div>
<div className="options">
<div className="caption">Options</div>
<div className="option">
<span>Selection Mode</span>
<SelectBox
items={selectionModes}
inputAttr={selectionModeLabel}
value={selectionMode}
onValueChange={onSelectionModeChange}>
</SelectBox>
</div>
<div className="option">
<span>Select All Mode</span>
<SelectBox
disabled={selectionMode !== 'all'}
items={selectAllModes}
inputAttr={selectAllModeLabel}
value={selectAllMode}
onValueChange={onSelectAllModeChange}>
</SelectBox>
</div>
<div className="option">
<span>Select By Click</span>
<CheckBox
value={selectByClick}
elementAttr={selectByClickLabel}
onValueChange={onSelectByClickChange}>
</CheckBox>
</div>
</div>
</React.Fragment>
);
}
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
List items can display checkboxes or radio buttons. To show these controls, enable the showSelectionControls property. Otherwise, users can click or tap list items to select them. The showSelectionControls property should also be enabled when you use the "all" selectionMode to show the Select All checkbox.
When the List data is paginated, you can choose whether the Select All checkbox selects all items on all pages or only the items on the current page. To configure this functionality, set the selectAllMode property to "allPages" or "page". In this demo, you can use the drop-down Select All Mode menu to change the selectAllMode property at runtime.
To configure the initial selection or access the keys of selected items, use the selectedItemKeys array. This example shows the contents of this array in the Selected IDs section below the List.
You can also implement the onSelectionChanged event handler to perform an action when users select items.