-
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 - Custom Editors
Different editors can be used to edit cell values in grid columns. The default editor depends on the column configuration. The dependency is illustrated in the editorOptions object's description (this object is used to customize the default editor). In this demo, the SelectBox component is the Status column's default editor, and the editorOptions object is used to specify the component's itemTemplate.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
@(Html.DevExtreme().DataGrid<DevExtreme.MVC.Demos.Models.CustomEditorsTask>()
.ID("gridContainer")
.DataSource(d => d.WebApi()
.RouteName("DataGridCustomEditors")
.LoadAction("Tasks")
.InsertAction("InsertTask")
.UpdateAction("UpdateTask")
.Key("ID")
)
.ShowBorders(true)
.Editing(editing => {
editing.Mode(GridEditMode.Cell);
editing.AllowUpdating(true);
editing.AllowAdding(true);
})
.SearchPanel(sp => sp.Visible(true))
.Pager(p => p.Visible(true))
.HeaderFilter(hf => hf.Visible(true))
.Paging(p => p.PageSize(15))
.OnRowInserted("function(e) { e.component.navigateToRow(e.key); }")
.Columns(columns => {
columns.AddFor(m => m.Owner)
.AllowSorting(false)
.Lookup(lookup => lookup
.DataSource(d => d.WebApi().RouteName("DataGridCustomEditors").LoadAction("Employees").Key("ID"))
.ValueExpr("ID")
.DisplayExpr("FullName")
)
.EditCellTemplate(new TemplateName("DropDownBoxTemplate"))
.Width(150);
columns.AddFor(m => m.AssignedEmployee)
.AllowSorting(false)
.Caption("Assignees")
.Lookup(lookup => lookup
.DataSource(d => d.WebApi().RouteName("DataGridCustomEditors").LoadAction("Employees").Key("ID"))
.ValueExpr("ID")
.DisplayExpr("FullName")
)
.CellTemplate(new JS("cellTemplate"))
.CalculateFilterExpression("calculateFilterExpression")
.EditCellTemplate(new TemplateName("TagBoxTemplate"))
.Width(200);
columns.AddFor(m => m.Subject);
columns.AddFor(m => m.Status)
.Width(200)
.EditorOptions(new {
itemTemplate = new JS("itemTemplate")
})
.Lookup(lookup => lookup
.DataSource(new JS("statuses"))
.ValueExpr("id")
.DisplayExpr("name")
);
})
)
@using(Html.DevExtreme().NamedTemplate("TagBoxTemplate")) {
@(Html.DevExtreme().TagBox()
.DataSource(d => d.WebApi().RouteName("DataGridCustomEditors").LoadAction("Employees").Key("ID"))
.Value(new JS("value"))
.ValueExpr("ID")
.InputAttr("aria-label", "Name")
.DisplayExpr("FullName")
.ShowSelectionControls(true)
.MaxDisplayedTags(3)
.ShowMultiTagOnly(false)
.ApplyValueMode(EditorApplyValueMode.UseButtons)
.SearchEnabled(true)
.OnValueChanged("function(e) { setValue(e.value); }")
.OnSelectionChanged("function(e) { component.updateDimensions(); }")
)
}
@using(Html.DevExtreme().NamedTemplate("DropDownBoxTemplate")) {
@(Html.DevExtreme().DropDownBox()
.DataSource(d => d.WebApi().RouteName("DataGridCustomEditors").LoadAction("Employees").Key("ID"))
.Value(new JS("value"))
.ValueExpr("ID")
.InputAttr("aria-label", "Owner")
.DisplayExpr("FullName")
.DropDownOptions(options => options.Width(500))
.Option("setValue", new JS("setValue"))
.ContentTemplate(new TemplateName("ContentTemplate"))
)
}
@using(Html.DevExtreme().NamedTemplate("ContentTemplate")) {
@(Html.DevExtreme().DataGrid()
.DataSource(d => d.WebApi().RouteName("DataGridCustomEditors").LoadAction("Employees").Key("ID"))
.RemoteOperations(true)
.Height(250)
.Columns(c => {
c.Add().DataField("FullName");
c.Add().DataField("Title");
c.Add().DataField("Department");
})
.Scrolling(s => s.Mode(GridScrollingMode.Virtual))
.HoverStateEnabled(true)
.Selection(s => s.Mode(SelectionMode.Single))
.SelectedRowKeys(new JS("component.option('value') !== undefined && component.option('value') !== null ? [component.option('value')] : []"))
.FocusedRowEnabled(true)
.FocusedRowKey(new JS("component.option('value')"))
.OnSelectionChanged("function(selectionChangedArgs) { onSelectionChanged(selectionChangedArgs, component) }")
)
}
<script>
function cellTemplate(container, options) {
var noBreakSpace = "\u00A0",
text = (options.value || []).map(element => {
return options.column.lookup.calculateCellValue(element);
}).join(", ");
container.text(text || noBreakSpace).attr("title", text);
}
function calculateFilterExpression(filterValue, selectedFilterOperation, target) {
if(target === "search" && typeof(filterValue) === "string") {
return [this.dataField, "contains", filterValue]
}
return function(data) {
return (data.AssignedEmployee || []).indexOf(filterValue) !== -1
}
}
function onSelectionChanged(selectionChangedArgs, component) {
var setValue = component.option('setValue');
var selectedRowKey = selectionChangedArgs.selectedRowKeys[0];
component.option('value', selectedRowKey);
setValue(selectedRowKey);
if(selectionChangedArgs.selectedRowKeys.length > 0) {
component.close();
}
}
function itemTemplate(itemData, itemIndex, itemElement) {
if(itemData != null) {
var imageContainer = $("<span>").addClass("status-icon middle").appendTo(itemElement);
$("<img>").attr("src", "../../Content/images/icons/status-" + itemData.id + ".svg").appendTo(imageContainer);
$("<span>").addClass("middle").text(itemData.name).appendTo(itemElement);
} else {
$("<span>").text("(All)").appendTo(itemElement);
}
}
</script>
<script src="~/Scripts/data/statuses.js"></script>
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
If the default editor is unsuitable, you can replace it with a custom editor. For this, implement an editCellTemplate that allows you to configure the replacement editor's appearance and behavior. To change the cell value and, optionally, the displayed value after the editor's value is changed, use the setValue() method of the editCellTemplate. In this demo, the default editors in the Owner and Assignees columns are replaced with the DropDownBox and TagBox components.