The new dgrid is designed to work with object stores, which makes it easy to create grids that are driven by real-time updates. This is a great feature for rapidly changing data like stock prices or game scores.
To make a dgrid update in real-time, we just need to back it with a real-time object store. This can be accomplished by simply wrapping it with the Observable store wrapper. If we start with a JsonRest object store that retrieves data through REST calls, we can wrap that with Observable:
var stockStore = new Observable(new JsonRest({
target:"./data/stocks.json"
}));
Now our stockStore is real-time ready. Next we have to write some code to notify listeners of changes in data. Observable stores provide a notify() method that we can call to notify the store of changes in data. Typically, for a real-time application with rapidly changing data, we would create a Comet connection to a server, and as we receive data from the server, we could notify our store, which would automatically trigger updates in the grid. This might look something like:
// create a socket or long-polling connection to a server and then listen for messages
mySocket.on("message", function(message){
// got a message
var data = message.data;
// assuming the data is the object to update, we can update the store with:
stockStore.notify(data, data.id);
});