-
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
-
Reporting
-
Interaction
-
Report Types
-
Data binding
-
Real-life Reports
-
Layout Features
-
Report Controls
-
Web-specific Features
-
-
Rich Text Editor
- Overview
- Load/Save
- Document Protection
-
Templates
- Autocorrect
-
Customization
- Simple View
-
Spreadsheet
- Overview
-
Open a Document
- Export And Printing
-
Features
-
UI Customization
-
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.
Data Grid - Real-Time Updates
The DataGrid component is optimized for real-time updates. You should bind it to a DataSource that contains a store and use the push(changes) method to update the store's data. The rows with changed data are rerendered (see the DataGrid's repaintChangesOnly property). The DataSource object also provides properties that control its behavior when it receives a push. For example, reshapeOnPush is set to true in this demo to allow summaries to be recalculated.
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
@(Html.DevExtreme().DataGrid()
.ID("gridContainer")
.DataSource(d => d.Array().Data(new JS("products")).Key("ProductID"))
.DataSourceOptions(o => o.ReshapeOnPush(true))
.RepaintChangesOnly(true)
.ColumnAutoWidth(true)
.ShowBorders(true)
.Paging(p => p.PageSize(10))
.Columns(c => {
c.Add()
.DataField("ProductName")
.DataType(GridColumnDataType.String);
c.Add()
.DataField("UnitPrice")
.DataType(GridColumnDataType.Number)
.Format(Format.Currency);
c.Add()
.DataField("OrderCount")
.DataType(GridColumnDataType.Number);
c.Add()
.DataField("Quantity")
.DataType(GridColumnDataType.Number);
c.Add()
.DataField("Amount")
.DataType(GridColumnDataType.Number)
.Format(Format.Currency);
})
.Summary(s =>
s.TotalItems(totalItems => {
totalItems.Add()
.SummaryType(SummaryType.Count)
.Column("ProductName");
totalItems.Add()
.SummaryType(SummaryType.Sum)
.DisplayFormat("{0}")
.ValueFormat(Format.Currency)
.Column("Amount");
totalItems.Add()
.SummaryType(SummaryType.Sum)
.DisplayFormat("{0}")
.Column("OrderCount");
})
)
.MasterDetail(md => {
md.Enabled(true);
md.Template(@<text>
@(Html.DevExtreme().DataGrid()
.DataSource(new JS("getDetailGridDataSource(key)"))
.RepaintChangesOnly(true)
.ColumnAutoWidth(true)
.ShowBorders(true)
.Paging(p => p.PageSize(5))
.Columns(c => {
c.Add()
.DataField("OrderID")
.DataType(GridColumnDataType.Number);
c.Add()
.DataField("ShipCity")
.DataType(GridColumnDataType.String);
c.Add()
.DataField("OrderDate")
.DataType(GridColumnDataType.DateTime);
c.Add()
.DataField("UnitPrice")
.DataType(GridColumnDataType.Number)
.Format(Format.Currency);
c.Add()
.DataField("Quantity")
.DataType(GridColumnDataType.Number);
c.Add()
.Caption("Amount")
.DataType(GridColumnDataType.Number)
.Format(Format.Currency)
.CalculateCellValue("getAmount")
.AllowSorting(true);
})
.Summary(s =>
s.TotalItems(totalItems => {
totalItems.Add()
.SummaryType(SummaryType.Count)
.Column("OrderID");
totalItems.Add()
.SummaryType(SummaryType.Sum)
.DisplayFormat("{0}")
.Column("Quantity");
totalItems.Add()
.SummaryType(SummaryType.Sum)
.DisplayFormat("{0}")
.ValueFormat(Format.Currency)
.Column("Amount");
})
)
)
</text>);
})
)
<script src="~/data/realTimeData.js"></script>
<script>
function getDetailGridDataSource(key) {
return {
store: ordersStore,
filter: ["ProductID", "=", key],
reshapeOnPush: true
}
}
function getAmount(order) {
return order.UnitPrice * order.Quantity;
}
function frequencyChanged(e) {
updatesPerSecond = e.value;
}
var updatesPerSecond = 100;
$(function () {
var productsStore = $("#gridContainer").dxDataGrid("getDataSource").store();
setInterval(function () {
if (orders.length > 500000) {
return;
}
for (var i = 0; i < updatesPerSecond / 20; i++) {
addOrder(productsStore);
}
}, 50)
});
</script>
<div class="options">
<div class="caption">Options</div>
<div class="option">
<span>Update frequency:</span>
@(Html.DevExtreme().Slider()
.ID("frequency-slider")
.Min(10)
.Max(5000)
.Step(10)
.Value(new JS("updatesPerSecond"))
.OnValueChanged("frequencyChanged")
.Tooltip(t => t
.Enabled(true)
.ShowMode(SliderTooltipShowMode.Always)
.Format("#0 per second")
.Position(VerticalEdge.Top)
)
)
</div>
</div>
using DevExtreme.NETCore.Demos.Models;
using DevExtreme.NETCore.Demos.Models.DataGrid;
using DevExtreme.NETCore.Demos.Models.SampleData;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
namespace DevExtreme.NETCore.Demos.Controllers {
public class DataGridController : Controller {
public ActionResult RealTimeUpdates() {
return View();
}
}
}
var cities = ["Los Angeles", "Denver", "Bentonville", "Atlanta", "Reno", "Beaver", "Malibu", "Phoenix", "San Diego", "Little Rock", "Pasadena", "Boise", "San Jose", "Chatsworth", "San Fernando", "South Pasadena", "San Fernando Valley", "La Canada", "St. Louis"];
var orders = [];
var ordersStore = new DevExpress.data.ArrayStore({
key: "OrderID",
data: orders
});
var products = [];
for (var i = 1; i <= 100; i++) {
products.push({ ProductID: i, ProductName: "Product " + i, UnitPrice: Math.floor(Math.random() * 1000) + 1, Quantity: 0, Amount: 0, OrderCount: 0 });
}
function addOrder(productsStore) {
var product = products[Math.round(Math.random() * 99)];
var order = {
OrderID: orders.length ? orders[orders.length - 1].OrderID + 1 : 20001,
ShipCity: cities[Math.round(Math.random() * (cities.length - 1))],
ProductID: product.ProductID,
UnitPrice: product.UnitPrice,
OrderDate: new Date(),
Quantity: Math.round(Math.random() * 20) + 1
};
ordersStore.push([{ type: "insert", data: order }]);
productsStore.push([{
type: "update",
key: order.ProductID,
data: {
OrderCount: product.OrderCount + 1,
Quantity: product.Quantity + order.Quantity,
Amount: product.Amount + order.UnitPrice * order.Quantity
}
}]);
}
.options {
padding: 20px;
margin-top: 20px;
background-color: rgba(191, 191, 191, 0.15);
}
.caption {
font-weight: 500;
font-size: 18px;
}
.option {
margin-top: 10px;
display: flex;
align-items: center;
}
.option > span {
position: relative;
top: 2px;
margin-right: 10px;
}
.option > .dx-widget {
width: 500px;
display: inline-block;
vertical-align: middle;
}
Grids in the detail sections are updated in real time as well. All the grids share the same ordersStore
that receives pushes, but it is filtered to show only a specific product's orders for each grid.