Angular UI-Grid onRegisterApi not firing

ui-grid-selection
ui-grid example
ui-grid columndefs
ui-grid-cell template
ui-grid tooltip
ui-grid-resize-columns
typeerror cannot read property on of undefined at object onregisterapi
ui-grid-auto-resize

I've been trying for hours to get this working. I load a few grids organized by data category, then I'd like to have another grid at the bottom of the page with all data category agnostic. The grids are hidden at first, so users can click on each individual category to see the respective grid, so I need to extract the api for each grid and call handleWindowResize() on them when they are clicked.

I think the problem is that onRegisterApi is not executing for the allData grid. Everything else works like a charm.

$scope.globalColumnDefs = [//column definitions here];
$scope.dataList = {};
$scope.allData = [];
$scope.gridOptions = [];
$scope.gridApis = [];
dataFactory.getData().success(function (data) {
        $scope.dataList = data.dataCategories;

        //set up each grid for data categories
        angular.forEach($scope.dataList, function (value) {
            $scope.allData = $scope.allData.concat(value.items);
            $scope.gridOptions.push({
                data: value.items,
                minRowsToShow: 25,
                showColumnFooter: true,
                enableFiltering: true,
                columnDefs: $scope.globalColumnDefs,
                onRegisterApi: function (api) {
                    $scope.gridApis.push(api);
                }
            });
        });

        //set up the allData grid
        $scope.gridOptions.push({
            data: $scope.allData,
            minRowsToShow: 25,
            showColumnFooter: true,
            enableFiltering: true,
            columnDefs: $scope.globalColumnDefs,
            onRegisterApi: function (api) {
                console.log("Regiestering API");
                $scope.gridApis.push(api);
            }
        });
    });

the console.log statement never fires (but it will if I put it in the first foreach loop). I started out with the loops combined and simply changing the data of the gridOptions object each time, but that didn't work. I also tried moving the allData to a new grid variable with new grid options with no luck.

Why isn't onRegisterApi firing for the allData grid??

I had a similar issue. That was because I forgot to put

<div ui-grid="gridOptions" ui-grid-selection class="grid"></div>

in the .html. Turns out that the ui-grid="griOptions" fires the onRegisterApi in the .js.

javascript - Angular UI-Grid onRegisterApi not firing, I had a similar issue. That was because I forgot to put <div ui-grid="gridOptions" ui-grid-selection class="grid"></div>. in the .html. Turns out that the  Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

onRegisterApi is called by ui-grid directive, so it's related to the rendering of the grid.

Here it seems you are adding the listener when some data gets returned, and this may as well happen after the rendering is complete. If this is the case (which is quite hard to say without a working example or a plunkr) then the listener will never get called.

My suggestion is to define the gridOptions inside of your controller (i.e. on page load) and then to use the dataFactory.getData().success promise to update only gridOptions' data property

OnRegisterApi not being called? · Issue #4619 · angular-ui/ui-grid , GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Sign up. This happens to me a lot. If I have a grid in a tab (for ex. tab#2) and tab#1 is showed on load, OnRegisterApi isn't called although I am already setting data to ui-grid so it is ready when the tab is clicked. Although for me this issue has easy workarounds so not a big problem.

Api has been alreadyd registered prior to your dataFactory request ended.

So you event was fired, but your listener was not attached yet.

onRegisterApi not working · Issue #5963 · angular-ui/ui-grid · GitHub, isRowHeader, \'custom\': true }" ui-grid-cell></div></div>', onRegisterApi : function​(gridApi) { $scope.gridApi = gridApi; alert('jjhjhj'); //not getting  angular-ui / ui-grid. Watch 382 rowSelectionChanged doesn't fire if a non-selectable row is Define a function for onRegisterApi that in turn defines a

$scope.globalColumnDefs = [//column definitions here];
 $scope.dataList = {};
 $scope.allData = [];
 $scope.gridOptions = [];
 $scope.gridOption = {
    minRowsToShow: 25,
    showColumnFooter: true,
    enableFiltering: true,
    columnDefs: $scope.globalColumnDefs,
    onRegisterApi: function (api) {
        alert('now it work')
        $scope.gridApis.push(api);
    }
};
$scope.gridApis = [];
dataFactory.getData().success(function (data) {
        $scope.dataList = data.dataCategories;

        //set up each grid for data categories
        angular.forEach($scope.dataList, function (value) {
            $scope.allData = $scope.allData.concat(value.items);

            $scope.gridOption.data = value.items;
            $scope.gridOptions.push($scope.gridOption);
        });

        //set up the allData grid
        $scope.gridOption.data = $scope.allData;
        $scope.gridOptions.push($scope.gridOption);

    });

javascript - Angular UI-Grid onRegisterApi not firing -, javascript - Angular UI-Grid onRegisterApi not firing - i've been trying hours working. load few grids organized data category, i'd have grid  QUID about a possibility to force the grid to resize without need to use "ui-grid-auto-resize" which impact performance because of timer (just need to resize first time grid is loaded) ?

Setting interval to 0 had solved my problem:

$interval(function (){
    $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN); }
    ,0);

onRegisterApi function not being called, ui-grid - angularjs, onRegisterApi function not being called, ui-grid - angularjs. It seems close to working but there is just something missing. If there is a better approach to have,​  HI PaulL, I am facing the same issue with UIGrid in SharePoint 2013, I am using UI-Grid to select few Items in the grid to have certain action on it, but couldn't get the selected rows by using the function mentioned in your sample above, even though I've downloaded the same "ui-grid-unstable.js", "ui-grid-unstable.css" from the sample and almost copied the same steps of configuring the grid

GridOptions, Note that this DOES add properties to your data that you may not want, but they are stripped out when using angular.toJson() . IF you do not want this at all you  ASP.NET Forums / General ASP.NET / Single Page Application / ng-click not working in ui grid AngularJS ng-click not working in ui grid AngularJS [Answered] RSS 1 reply

GridApi, gridOptions.onRegisterApi = function(gridApi) {; gridApi. the listener. It's not necessary to use it as the listener will be removed when the scope is destroyed. Join a community of over 2.6m developers to have your questions answered on Databound event not firing of Kendo UI for jQuery Grid. New here? Start with our free trials.

Angular UI Grid - how to change view on row select, I have tried in my grid definition: onRegisterApi: function (gridApi ) { $scope. I have added ui.grid and ui.grid.selection to my angular.module. How select the first Row default in UI-Grid in Angular JS: I tried below code, but it is not working:​  angular ui-grid pagination v3.0.0-RC.18 not working javascript,angularjs,angular-ui-grid How do you get pagination to work/controls to appear using angular ui-grid? Has anyone successfully done it? I am aware of the tutorial.

Comments
  • Any chance of creating a plunker?
  • Please add comments regarding what has been changed and why.
  • OP is asking how to get onRegisterApi to fire which is the place where you could get a reference on gridApi, so it's clearly not related to what you answered.
  • @imbalind onRegisterApi won't fire until data is rendered on UI.. OP has mentioned that the grids are hidden.. Setting interval is the only solution as mentioned here
  • That problem seems resolved: as you can see tutorial 308 doesn't use $interval anymore (although the dependency is still there) and I used hidden grids many times without the need to use your suggested solution anywhere. I think we'd better wait for the OP to publish a plunker and see what's causing this.