title: Automatically refresh dgrid contents
body: <p>I am using a dgrid <code>OnDemandGrid</code> to display data from a Dojo <code>JsonRest</code> store. This works well but I want the grid to automatically display changed data. Implementing a push-based approach where the server tells all clients which data has changed is too much effort, so I am looking for a client-based solution. Using dgrid's <code>refresh()</code> is not useful, since this causes flickering and resets the whole grid. </p>
  
  <p>My best guess so far is to periodically fetch all data from a second store instance, compare this to the live store instance and use the <code>Observable</code> store wrapper to notify the grid of any changed data. </p>
  
  <p>Is there a better, more elegant solution? If not, how do I do this best?</p>
  
  <p><strong>edit:</strong> The problem with this approach is to know which rows are currently displayed in the grid. My app works with large amounts of data so syncing the whole set in two dojo stores is not a good idea. Is there a way to tell which rows are currently displayed in the grid? Ideally, the grid would just periodically re-request data for the currently displayed rows. Can't be that hard, right?</p>
  
  <p><strong>edit2:</strong> My best approach so far is to "hack" the <code>Observable</code> store, keeping track of all calls to <code>observe</code>. I would then periodically re-execute the observed queries and merge changes into the live store. 
  The problem is that dgrid keeps way too many observers open for this to work smoothly. It closes some of them, so there is no error in my code, and I set <code>farOffRemoval</code> to 500 (also tried lower and higher).</p>
  
  <p>This is my code so far: <a href="https://gist.github.com/3225927" rel="nofollow">https://gist.github.com/3225927</a></p>
  
  <p>It's nowhere finished but it displays enough debug info to show where the problem is. Since probably nobody wants to set this up and there is no dgrid on jsfiddle, I can tell you that after some scrolling in a 1000 entry grid there are about 10-15 observers and observerStats.abs (count of all rows that are at least observed once) is about 750.</p>