-
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 - Command Column Customization
The DataGrid supports multiple predefined types of command columns. Each column type supports one type of action (edit, select, drag, etc.). This demo shows how to customize the Edit Command Column. This column type contains predefined edit buttons and optional custom buttons.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
@(Html.DevExtreme().DataGrid()
.DataSource(new JS("employees"))
.KeyExpr("ID")
.Paging(paging => paging.Enabled(false))
.ShowBorders(true)
.Editing(editing => {
editing.Mode(GridEditMode.Row);
editing.AllowUpdating(true);
editing.AllowDeleting(new JS("allowDeleting"));
editing.UseIcons(true);
})
.Columns(columns => {
columns.Add()
.Type(GridCommandColumnType.Buttons)
.Width(110)
.Buttons(b => {
b.Add().Name(GridColumnButtonName.Edit);
b.Add().Name(GridColumnButtonName.Delete);
b.Add()
.Hint("Clone")
.Icon("copy")
.Visible(new JS("isCloneIconVisible"))
.Disabled(new JS("isCloneIconDisabled"))
.OnClick("onCloneIconClick");
});
columns.Add()
.DataField("Prefix")
.Caption("Title");
columns.Add().DataField("FirstName");
columns.Add().DataField("LastName");
columns.Add()
.DataField("Position")
.Width(130);
columns.Add()
.DataField("StateID")
.Caption("State")
.Width(125)
.Lookup(lookup => lookup
.DataSource(new JS("states"))
.DisplayExpr("Name")
.ValueExpr("ID")
);
columns.Add()
.DataField("BirthDate")
.DataType(GridColumnDataType.Date)
.Width(125);
})
.OnRowValidating("onRowValidating")
.OnEditorPreparing("onEditorPreparing")
)
<script src="~/Scripts/data/employeeData.js"></script>
<script>
var maxID = employees[employees.length - 1].ID;
function isChief(position) {
return position && ["CEO", "CMO"].indexOf(position.trim().toUpperCase()) >= 0;
};
function allowDeleting(e) {
return !isChief(e.row.data.Position);
}
function isCloneIconVisible(e) {
return !e.row.isEditing;
}
function isCloneIconDisabled(e) {
return isChief(e.row.data.Position);
}
function onCloneIconClick(e) {
var clonedItem = $.extend({}, e.row.data, { ID: ++maxID });
employees.splice(e.row.rowIndex, 0, clonedItem);
e.component.refresh(true);
e.event.preventDefault();
}
function onRowValidating(e) {
var position = e.newData.Position;
if (isChief(position)) {
e.errorText = "The company can have only one " + position.toUpperCase() + ". Please choose another position.";
e.isValid = false;
}
}
function onEditorPreparing(e) {
if (e.parentType === "dataRow" && e.dataField === "Position") {
e.editorOptions.readOnly = isChief(e.value);
}
}
</script>
xxxxxxxxxx
xxxxxxxxxx
Predefined buttons
The available selection of predefined buttons depends on the selected edit mode, and the availability of the update and delete operations. To enable them, set the allowUpdating and allowDeleting properties to true. You can also set any of these properties to a custom function that enables the corresponding operation and displays its button only for certain rows.
This demo has the following configuration:
-
Edit mode is set to "row".
-
allowUpdating is enabled to display Edit buttons in all rows.
-
allowDeleting is set to a function that hides the Delete button based on a custom condition.
The predefined edit buttons are displayed as textual links by default. To use icons instead, set the useIcons property to true.
Custom buttons
If a command column should contain custom buttons, add its configuration to the columns array. DataGrid will display this column according to its position in this array. Specify the column's type as "buttons" and declare the buttons array. It should contain your custom buttons along with the predefined buttons. If you need to customize a predefined button, add an object with specified name and other button properties. If customization is not required, add only button names.
In this demo, the edit column contains one custom button (Clone) and two predefined buttons (Edit and Delete) without customization.