[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [Expand]Grid View Data Layout
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Expand]Selection
   [Expand]Filtering and Searching
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus and Navigation
   [Expand]Conditional Formatting
   [Expand]Drag-and-Drop
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Collapse]Examples
    [Collapse]Binding to Data
      How to: Automatically Create Grid Columns
      How to: Bind a Grid to Data (eXpress Persistent Objects)
      How to: Bind a Grid to an MS Access Database
      How to: Bind a Grid to an XML File
      How to: Bind a Grid to an ICollectionView
      How to: Bind the GridControl to XPO
      How to: Apply Data Annotations
      How to: Post Changes to SQL Database
      How to: Display Unbound Data
      How to: Create a Master-Detail Grid
      How to: Bind Card Headers to Data
      How to: Customize Automatically Generated Columns
      How to: Bind the Grid to Columns and Summaries Specified in ViewModel
      How to: Create a Banded View
      How to: Display Data Which is Being Updated on Another Thread
      How to: Use DXGrid in Server Mode with Entity Framework 4.0+
      How to: Activate the Instant Feedback Mode for the Grid Bound to the Entity Framework 4.0 Classes
      How to: Implement the Instant Feedback Mode (XPO)
      How to: Parallelize Data-Intensive Operations On In-Memory Data in Instant Feedback UI Mode
      How to: Speed Up Performance When Using WCF Data Services (OData) in Instant Feedback Mode
    [Expand]Master-Detail
    [Expand]Hierarchical Data Presentation
    [Expand]Sorting, Grouping and Filtering
    [Expand]Calculating Summaries
    [Expand]Data Editing and Validation
    [Expand]Focus and Navigation
    [Expand]Drag-and-Drop
    [Expand]Styles and Templates
    [Expand]End-User Interaction
    [Expand]Miscellaneous
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Display Data Which is Being Updated on Another Thread

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E3322.

Let's suppose that your data is being updated on another thread, by the timer in this example. You should take a special action to correctly reflect those changes in the grid - wrap them inside BeginDataUpdate/EndDataUpdate calls.


When using the MVVM pattern, it is not possible to call grid's methods directly from the view model. Your view model can provide additional events to expose such changes of its state to the view. There are OnAsyncProcessingStarted and OnAsyncProcessingCompleted events in this example. Now you can handle these events in the view and force the grid to stop/start listening for data updates before/after asynchronous data modifications.


Please note even though this approach requires several code lines in View's code-behind, ViewModel in this situation is completely independent from GridControl. Thus, this approach conforms the MVVM pattern.


UPDATED:



After we introduced Services, the same task can be implemented by creating a custom service (How to create a Custom Service). This service will have access to the GridControl in the View, and will contain the required BeginUpdate and EndUpdate methods. In these methods, GridControl's BeginDataUpdate  and EndDataUpdate  methods will be called.


Starting with v13.1.4, this example illustrates this approach.


 
See also:

Services in ViewModelBase descendants
Services in POCO Objects  
Services in custom ViewModels

Is this topic helpful?​​​​​​​