ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

I am not able to call refresh() on grid.

Open rkrishnadudyala opened this issue 11 years ago • 10 comments

Can some on provide me some pointers on how we call refresh() method. Any examples?

Thanks.

rkrishnadudyala avatar Dec 17 '14 18:12 rkrishnadudyala

2.x or 3.0?

PaulL1 avatar Dec 17 '14 18:12 PaulL1

I am using 3.0.0-rc.16

rkrishnadudyala avatar Dec 17 '14 18:12 rkrishnadudyala

OK, look in the tutorials for some that do onRegisterApi.

Do that, and then call $scope.gridApi.core.refresh()

PaulL1 avatar Dec 17 '14 19:12 PaulL1

Thanks Paul for the response. I tried but that does not help.

  $scope.gridOptions.onRegisterApi = function(gridApi){
      //set gridApi on scope
      $scope.gridApi = gridApi;
      gridApi.selection.on.rowSelectionChanged($scope,function(row){
        var msg = 'row selected ' + row.isSelected;
        $log.log(msg);
      });

      gridApi.selection.on.rowSelectionChangedBatch($scope,function(rows){
        var msg = 'rows changed ' + rows.length;
        $log.log(msg);
      });
    };

$scope.gridApi.core.refresh();

But I am getting below error

Error: [jqLite:nosel] Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element http://errors.angularjs.org/1.2.25/jqLite/nosel at http://localhost:8080/test/resources/js/lib/angular-1.2.25/angular.js:78:12 at JQLite (http://localhost:8080/test/resources/js/lib/angular-1.2.25/angular.js:2375:13) at compile (http://localhost:8080/test/resources/js/lib/angular-1.2.25/angular.js:5966:25) at pre (http://localhost:8080/test/resources/js/lib/3.0.0-rc.16/ui-grid.js:859:30) at http://localhost:8080/test/resources/js/lib/angular-1.2.25/angular.js:7113:44 at nodeLinkFn (http://localhost:8080/test/resources/js/lib/angular-1.2.25/angular.js:6691:13) at compositeLinkFn (http://localhost:8080/test/resources/js/lib/angular-1.2.25/angular.js:6105:13) at publicLinkFn (http://localhost:8080/test/resources/js/lib/angular-1.2.25/angular.js:6001:30) at boundTranscludeFn (http://localhost:8080/test/resources/js/lib/angular-1.2.25/angular.js:6125:21) at controllersBoundTransclude (http://localhost:8080/test/resources/js/lib/angular-1.2.25/angular.js:6732:18)

rkrishnadudyala avatar Dec 17 '14 20:12 rkrishnadudyala

The gridApi doesn't exist immediately, so if you call $scope.gridApi.core.refresh() immediately, it won't yet be instantiated.

Having said that, the error you have looks to have nothing to do with that. What is at line 859 of ui-grid.js in your build - what method is it in, of which module?

PaulL1 avatar Dec 17 '14 20:12 PaulL1

Also, tangentially, for what reason are you calling refresh? Perhaps there is a different way to achieve your outcome - in general you shouldn't need to call refresh manually.

PaulL1 avatar Dec 17 '14 20:12 PaulL1

Assuming that original issue is resolved, no comments for 3 weeks.

PaulL1 avatar Jan 10 '15 20:01 PaulL1

yes, it works! @PaulL1 thank u!

JavaBasketball avatar Oct 15 '15 04:10 JavaBasketball

Hi, I am using the ui-grid and th eupdate of model does not update the grid (view). When I perform a sort it updates the data. How can I perform refresh in this case? Thanks in advance!

Ankita10 avatar Mar 17 '16 12:03 Ankita10

got it to work using gridApi.core.refresh() but is there a better way to achieve it?

Ankita10 avatar Mar 17 '16 12:03 Ankita10