0

I'm trying to get a callback from the Angular UI grid (after data is loaded/rendered) but it doesn't seem to work for me.

I'm following this which says I should listen the scope using $scope.$on() and I tried this which implies I can provide a dataUpdated() and init() delegate through the options.

In both cases I don't see anything in my console... The grid renders fine and I can also see a console entry stating: 'grid refresh'.

I'm loading the grid with the following options:

$scope.$on('ngGridEventRows', function (event) {
    console.log('rendering');
});

$scope.$on('ngGridEventRows', function (event) {
    console.log('rendering');
});

        $scope.options = {
            enableSorting: true,
            //data: myData,
            dataUpdated: function() {
                console.log('dataUpdated');
            },
            init: function () {
                console.log('init');
            }
        };

    $scope.grids = [$scope.options];

The options are passed to the grid as follows:

<div class="container-fluid" ng-repeat="grid in grids">
    <div ui-grid="grid" ui-grid-exporter></div>
</div>
2
  • How do you pass that $scope.options object to your grid? Commented Nov 13, 2015 at 15:29
  • @Starscream1984: I'm actually putting it in an array first, please check my updated question. Commented Nov 13, 2015 at 15:48

1 Answer 1

4

Those events are related to ng-grid (probably version 2.x) while you are using ui-grid (which is a rename of ng-grid version 3.0).

I'd suggest you to give a look at the updated website ui-grid.info where you can find docs and tutorials about the current version.

Regarding your peculiar need sadly it seems there is no documented event you can use, but looking through the code I found the following:

$scope.grid.api.core.on.rowsRendered( $scope, function() );

You should put this in your gridOptions.onRegisterApi(...) and the function will be called upon rendering is complete (or so it seems looking at the source).

I'd suggest you to play a bit with it and see what it can do.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.