RealGrid2 Guide
Get data
Lazy Loading Example

LazyLoading

Lazy loading in a grid can be implemented by reading the next data when scrolling to the last row. RealGrid provides scroll-related callback functions to implement this behavior.

Get the next data when scrolled to the last row

Lazy Loading can be implemented using the GridBase.onScrollToBottom() callback function, which is called when the grid is scrolled to the last row.

gridView.onScrollToBottom = function() {
   httpRequest = new XMLHttpRequest();
   httpRequest.onreadystatechange = function() {
     if (httpRequest.readyState === XMLHttpRequest.DONE) {
       if (httpRequest.status === 200) {
         var data = JSON.parse(httpRequest.responseText);
         dataProvider.fillJsonData(data, {
           fillMode: "append",
           noStates: true
         });
         gridView.refresh();
       }
     }
   };
   httpRequest.open("GET", "/data/" + simple_data.json);
   httpRequest.send();
};