-
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
Data Grid - Toolbar Customization
If you have technical questions, please create a support ticket in the DevExpress Support Center.
@using DevExtreme.MVC.Demos.Models
@model IEnumerable<Order>
@(Html.DevExtreme().DataGrid<Order>()
.ID("gridContainer")
.DataSource(Model, new[] { "ID" })
.ShowBorders(true)
.ColumnChooser(c => c.Enabled(true))
.LoadPanel(p => p.Enabled(true))
.Columns(columns => {
columns.AddFor(m => m.OrderNumber);
columns.AddFor(m => m.OrderDate);
columns.AddFor(m => m.Employee);
columns.AddFor(m => m.CustomerStoreCity);
columns.AddFor(m => m.CustomerStoreState)
.GroupIndex(0);
columns.AddFor(m => m.SaleAmount)
.Alignment(HorizontalAlignment.Right)
.Format(Format.Currency);
})
.Toolbar(toolbar => {
toolbar.Items(items => {
items.Add()
.Location(ToolbarItemLocation.Before)
.Template(@<div class="informer"><div class="count"></div><span>Total Count</span></div>);
items.Add()
.Location(ToolbarItemLocation.Before)
.Widget(w =>
w.SelectBox()
.Width(225)
.InputAttr("aria-label", "State")
.DataSource(new[] {
new { value = "CustomerStoreState", text = "Grouping by State" },
new { value = "Employee", text = "Grouping by Employee" },
})
.DisplayExpr("text")
.ValueExpr("value")
.Value("CustomerStoreState")
.OnValueChanged("selectboxValueChanged")
);
items.Add()
.Location(ToolbarItemLocation.Before)
.Widget(w =>
w.Button()
.Width(136)
.Text("Collapse All")
.OnClick("collapseButtonClicked")
);
items.Add()
.Location(ToolbarItemLocation.After)
.Widget(w =>
w.Button()
.Icon("refresh")
.OnClick("refreshButtonClicked")
);
items.Add()
.Name("columnChooserButton");
});
})
)
<script>
var dataGrid;
function selectboxValueChanged(e) {
dataGrid.clearGrouping();
dataGrid.columnOption(e.value, "groupIndex", 0);
$(".informer .count").text(getGroupCount(e.value));
}
function collapseButtonClicked(e) {
var expanding = e.component.option("text") === "Expand All";
dataGrid.option("grouping.autoExpandAll", expanding);
e.component.option("text", expanding ? "Collapse All" : "Expand All");
}
function refreshButtonClicked(e) {
dataGrid.refresh();
}
function getGroupCount(groupField) {
var orders = [];
$("#gridContainer").dxDataGrid("instance")
.option("dataSource")
.store
.load()
.done(function (data) {
orders = data;
});
return DevExpress.data.query(orders)
.groupBy(groupField)
.toArray().length;
}
$(function () {
dataGrid = $("#gridContainer").dxDataGrid("instance");
$(".informer .count").text(getGroupCount("CustomerStoreState"));
});
</script>
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
This demo illustrates how to add the following items to the toolbar:
-
Predefined Controls
Declare a toolbar item element and specify the name and properties that you want to customize. If a control does not need customization, include its name only. Ensure that items[] contain controls for all features that you enabled in your DataGrid. In this demo, we enable the columnChooser and add the "columnChooserButton" to the items[] array. -
DevExtreme Components
Configure the desired DevExtreme component within a toolbar item element. In this demo, we extended the toolbar's item collection with a Button and a SelectBox. -
Custom Elements
Specify a template for your custom element within a toolbar item. In this demo, the custom element displays the total group count.