mleibman/SlickGrid — Issue #265: Bug in slick.remotemodel.js leaves "Buffering..." indicator stuck on, solved.
Author: rohanc
Created: 2012-01-10 06:41:29+00:00
State: open

My application uses a modified version of SlickGrid example 6 (AJAX), which uses slick.remotemodel.js. I noticed that in some circumstances, the "Buffering..." indicator gets stuck on. It usually happens after I do lots of scrolling within the grid.

The "Buffering" indicator is a pop-up window drawn by code in this file:
http://mleibman.github.com/SlickGrid/examples/example6-ajax-loading.html

After some debugging, I realised that this happened when the .jsonp request was being manually aborted and not restarted. This is due to a bug in remotemodel.js, within the ensureData(from,to) function within slick.remotemodel.js. Here is an unmodified excerpt:

```javascript
if (fromPage > toPage || ((fromPage == toPage) && data[fromPage*PAGESIZE] !== undefined)) {
// TODO: look-ahead
return;
}
```

To solve the bug, I added the following line before the "return":
onDataLoaded.notify({from:from, to:to});

For anyone who's interested, it happened to me when the following condition was satisfied:
((fromPage == toPage) && data[fromPage*PAGESIZE] !== undefined))

I don't think it's relevant, but I use Firefox 9 and recent version of Slickgrid v2.0 alpha, downloaded Jan 2012.