-
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 - Column Chooser
To change column visibility at runtime, set the columnChooser.enabled property to true. To make certain that a given column(s) always stay visible, set the columns[].allowHiding property to false.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
@using DevExtreme.MVC.Demos.Models.DataGrid
@using DevExtreme.MVC.Demos.Models
@model IEnumerable<Employee>
@(Html.DevExtreme().DataGrid<Employee>()
.ID("gridContainer")
.DataSource(Model)
.KeyExpr("ID")
.Columns(column => {
column.AddFor(m => m.FirstName)
.AllowHiding(false);
column.AddFor(m => m.LastName);
column.AddFor(m => m.Position);
column.AddFor(m => m.City);
column.AddFor(m => m.State);
column.Add()
.Caption("Contacts")
.Columns(a => {
a.AddFor(m => m.Phone)
.AllowHiding(false);
a.AddFor(m => m.Email);
a.AddFor(m => m.Skype)
.Visible(false);
});
column.AddFor(m => m.HireDate);
})
.ColumnAutoWidth(true)
.Width("100%")
.ShowRowLines(true)
.ShowBorders(true)
.ColumnChooser(cc => {
cc
.Enabled(true)
.Height("340px")
.Mode(GridColumnChooserMode.Select)
.Position(pc => pc
.My(HorizontalAlignment.Right, VerticalAlignment.Top)
.At(HorizontalAlignment.Right, VerticalAlignment.Bottom)
.Of(".dx-datagrid-column-chooser-button")
);
cc.Search(ccs => ccs
.Enabled(true)
.EditorOptions(new { Placeholder = "Search column" })
);
cc.Selection(ccs => ccs
.AllowSelectAll(true)
.SelectByClick(true)
.Recursive(true)
);
})
)
<div class="options">
<div class="caption">Options</div>
<div class='selectboxes-container'>
<div class="option">
<span>Column chooser mode</span>
@{
var dataSource = new[] {
new ColumnChooserMode {
Key = "dragAndDrop",
Name = "Drag and drop"
},
new ColumnChooserMode {
Key = "select",
Name = "Select"
}
};
}
@(Html.DevExtreme().SelectBox()
.DataSource(dataSource)
.Value(dataSource[1].Key)
.ValueExpr("Key")
.InputAttr("aria-label", "Column Chooser Mode")
.DisplayExpr("Name")
.OnValueChanged(@<text>
function(data) {
var dataGrid = $("#gridContainer").dxDataGrid("instance");
dataGrid.option("columnChooser.mode", data.value);
const isDragMode = dataSource[0].key === data.value;
$('#allowSelectAll').dxCheckBox('instance').option('disabled', isDragMode);
$('#selectByClick').dxCheckBox('instance').option('disabled', isDragMode);
$('#recursive').dxCheckBox('instance').option('disabled', isDragMode);
}
</text>)
)
</div>
</div>
<div class='checkboxes-container'>
<div class="option">
@(Html.DevExtreme().CheckBox()
.Text("Search enabled")
.Value(true)
.OnValueChanged(@<text>
function(data) {
var dataGrid = $("#gridContainer").dxDataGrid("instance");
dataGrid.option("columnChooser.search.enabled", data.value);
}
</text>)
)
</div>
<div class="option">
@(Html.DevExtreme().CheckBox()
.ID("allowSelectAll")
.Text("Allow select all")
.Value(true)
.OnValueChanged(@<text>
function(data) {
var dataGrid = $("#gridContainer").dxDataGrid("instance");
dataGrid.option("columnChooser.selection.allowSelectAll", data.value);
}
</text>)
)
</div>
<div class="option">
@(Html.DevExtreme().CheckBox()
.ID("selectByClick")
.Text("Select by click")
.Value(true)
.OnValueChanged(@<text>
function(data) {
var dataGrid = $("#gridContainer").dxDataGrid("instance");
dataGrid.option("columnChooser.selection.selectByClick", data.value);
}
</text>)
)
</div>
<div class="option">
@(Html.DevExtreme().CheckBox()
.ID("recursive")
.Text("Recursive")
.Value(true)
.OnValueChanged(@<text>
function(data) {
var dataGrid = $("#gridContainer").dxDataGrid("instance");
dataGrid.option("columnChooser.selection.recursive", data.value);
}
</text>)
)
</div>
</div>
</div>
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
To display the column chooser, click the appropriate toolbar button above the DataGrid. You can specify the column chooser's position via the columnChooser.position property. The manner in which users can display/hide columns depends on columnChooser.mode:
-
"dragAndDrop"
Users can drag and drop column headers to and from the column chooser. -
"select"
Users can select and deselect check boxes with column names.
In "select" mode, you can choose whether parent element selection affects child/nested elements. Use the selection.recursive property for this purpose.
If the column chooser contains multiple hidden columns, you can enable the DevExtreme Grid’s column search UI. Assign true to the search.enabled property for this purpose.
In this demo, use the check boxes below the DataGrid to toggle search and selection features.
To hide a column in code, set the columns[].visible property to false.