0
     $http.get('resturl').success(function (data) { //makes a rest call here
          $scope.myData = data;
     }); 

The data loads in grid only after request completes. I have very large data so this makes user to wait for 2 min - 3 min to load grid. Is there a way to render large data quickly ?

3 Answers3

0

Use pagination data in server side for large data sets and show it to your users with a paginated grid.

In this question you have an example of paginated nggrid

Community
  • 1
  • 1
José Ricardo Pla
  • 1,043
  • 10
  • 16
0

Oneway binding makes things faster use :: see Simple One way binding for ng-repeat? , can you reduce your data? also look at paging ?

Is your server slow, I have found that doing something like

$http.get('resturl').success(function (data) { //makes a rest call here
          console.log("Request Complete");
          $scope.myData = data;
          $timeout(function () { console.log("Binding complete"); });
     }); 

The log in the timer will get executed once the binding is complete.

Understanding the contents your grid will also help.

Community
  • 1
  • 1
Steve Drake
  • 1,968
  • 2
  • 19
  • 41
0
$scope.pagingOptions = {

pageSizes: [5, 7,10, 20],

pageSize: 7,

currentPage: 1

};



$scope.setPagingData = function(data, page, pageSize)
 {

var pagedData = data.slice((page - 1) * pageSize, page * pageSize);

$scope.myData = pagedData;

$scope.totalServerItems = data.length;

if (!$scope.$$phase) {

$scope.$apply();

}

};

$scope.getPagedDataAsync = function(pageSize, page, searchText) {

setTimeout(function() {

var data;

if (searchText) {

var ft = searchText.toLowerCase();

$http.get('largeLoad.json').success(function(largeLoad) {

data = largeLoad.filter(function(item) {

return JSON.stringify(item).toLowerCase().indexOf(ft) != -1;

});

$scope.setPagingData(data, page, pageSize);

});

} 
else {

$http.get('largeLoad.json').success(function(largeLoad) {

$scope.setPagingData(largeLoad, page, pageSize);

var myData =  $.parseJSON(JSON.parse(largeLoad));

$scope.myData  =  myData; 

});


}

}, 100);

};


$scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage);


$scope.$watch('pagingOptions', function(newVal, oldVal) {

if (newVal !== oldVal && newVal.currentPage !== oldVal.currentPage) {

$scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage);

}

}, true);

may be this code will help you for providing pagination too with fast loading of JSON data.

Dannie
  • 11
  • 7