Pull down to refresh...
Release to refresh...
Refreshing...
-
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
- 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
-
Maps
- Overview
-
Map
-
Vector Map
-
Dialogs and Notifications
-
Localization
Related Demos:
Your search did not match any results.
Loading...
Data Grid - Multiple Record Selection API
DataGrid has the following API for multiple record selection:
-
selectAll() / deselectAll()
Selects / deselects all rows or current page rows, depending on the value of selectAllMode. -
selectRows(keys, preserve) / deselectRows(keys)
Selects / deselects rows with the specified keys. -
selectRowsByIndexes(indexes)
Selects rows with specific indexes. -
clearSelection()
Clears the selection of all rows on all pages. -
getSelectedRowKeys() / getSelectedRowsData()
Gets the selected rows' keys or data objects.
Was this demo helpful?
Feel free to share demo-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Backend API
x
@using DevExtreme.MVC.Demos.Models.DataGrid
@model IEnumerable<Employee>
@(Html.DevExtreme().DataGrid<Employee>()
.ID("grid-container")
.DataSource(Model, new[] { "ID" })
.ShowBorders(true)
.Selection(s => s.Mode(SelectionMode.Multiple))
.Columns(columns => {
columns.AddFor(m => m.Prefix)
.Width(70);
columns.AddFor(m => m.FirstName);
columns.AddFor(m => m.LastName);
columns.AddFor(m => m.Position)
.Width(180);
columns.AddFor(m => m.BirthDate)
.Width(125);
columns.AddFor(m => m.HireDate)
.Width(125);
})
.OnSelectionChanged("selection_changed")
.Toolbar(toolbar => {
toolbar.Items(items => {
items.Add()
.Location(ToolbarItemLocation.Before)
.Widget(w =>
w.SelectBox()
.DataSource(new[] { "All", "Dr.", "Mr.", "Mrs.", "Ms." })
.Placeholder("Select title")
.InputAttr("aria-label", "Title")
.OnValueChanged("selectBox_valueChanged")
.OnInitialized("selectBox_onInitialized")
);
items.Add()
.Location(ToolbarItemLocation.Before)
.Widget(w =>
w.Button()
.Text("Clear Selection")
.Disabled(true)
.OnClick("button_click")
.OnInitialized("button_onInitialized")
);
});
})
)
<div class="selected-data">
<span class="caption">Selected Records:</span>
<span id="selectedItemsContainer">Nobody has been selected</span>
</div>
<script>
var changedBySelectBox;
var titleSelectBox;
var clearSelectionButton;
function getDataGridInstance() {
return $("#grid-container").dxDataGrid("instance");
}
function selection_changed(selectedItems) {
var dataGrid = getDataGridInstance();
var data = selectedItems.selectedRowsData;
if(data.length > 0) {
$("#selectedItemsContainer").text(
data
.map((value) => `${value.FirstName} ${value.LastName}`)
.join(", ")
);
} else {
$("#selectedItemsContainer").text("Nobody has been selected");
}
if (!changedBySelectBox) {
titleSelectBox.option('value', null);
}
changedBySelectBox = false;
clearSelectionButton.option('disabled', !data.length);
}
function selectBox_valueChanged(data) {
if(!data.value)
return;
var dataGrid = getDataGridInstance();
changedBySelectBox = true;
if(data.value == "All") {
dataGrid.selectAll();
} else {
var employeesToSelect = dataGrid.getDataSource().items()
.filter((employee) => employee.Prefix === data.value)
.map((employee) => employee.ID);
dataGrid.selectRows(employeesToSelect);
}
}
function selectBox_onInitialized(e) {
titleSelectBox = e.component;
}
function button_onInitialized(e) {
clearSelectionButton = e.component;
}
function button_click() {
getDataGridInstance().clearSelection();
}
</script>
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
In this demo, selectAll() or selectRows(keys, preserve) is called when you change the SelectBox value and clearSelection() is called when you click the Clear Selection button.