Most bottlenecks occur on the backend (database retrieval).
To reduce the effect of slowness, you can adopt this method that I used.
- Enhance your backend api to support server side paging calls
- Refactor your loading ajax calls to do a small size call (e.g. top 400 rows).
- On completion of this first load, check if there's any more records. If yes, set a recursive load until complete.
Now, the user will 'see' those first 400 rows, while its still loading the remaining 3600 rows. This is where you need to display a loading icon to show progress.
Below's a sample of codes to load this.
var myList = [];
var loadDataFunc = function( start, limit ) {
_self.Status.IsLoading = true;
$http
.get( DataUrl + "?start=" + start + "&limit=" + limit)
.then(function(response){
if( response && response.data && response.data.List) {
if( response.data.Total > 0 ) {
for( var z = 0; z < response.data.List.length; z++ ) {
myList.push(response.data.List[z]);
}
var currentItemsLoaded = start + response.data.List.length;
if( currentItemsLoaded < response.data.Total ) {
//means we still have pending to load, then we load again!
setTimeout(function(){
loadDataFunc(currentItemsLoaded, limit);
}, 500);
}else {
//If it reaches here, it means we have completed loading
_self.Status.IsLoading = false;
_self.Status.IsLoaded = true;
}
BindDataToGrid();
} else {
_self.Status.IsLoading = false;
_self.Status.IsLoaded = true;
if( start === 0 ) {
BindDataToGrid();
}
}
}
else {
_self.Status.IsLoading = false;
_self.Status.IsLoaded = true;
}
})
.catch(function(response){
_self.Status.IsLoading = false;
//error!
});
};
function BindDataToGrid () {
setTimeout(function(){
grid.api.setRowData(myList);
},100);
};