Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to display data which is being updated on another thread

$
0
0

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.

 


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>