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

removeFromGridMenu TypeError

Open chyzwar opened this issue 11 years ago • 2 comments

      /**
       * Init grid api
       */
      scope.gridOptions.onRegisterApi = function (gridApi) {
        scope.gridApi = gridApi;

        //Remove "Clear All Filters" from GridMenu
        scope.gridApi.core.removeFromGridMenu(gridApi.grid, 0);
       };

I want to remove Clear All Filters from gridMenu. When I try to call removeFromGridMenu I get:

TypeError: scope.gridApi.core.removeFromGridMenu is not a function

How I can call this function ? What would be correct way when I try to remove 'Clear all Filters'?

I also tried to remove Clear all Filters from menuItems array but this array is regenerated each time gridMenu is opened.

chyzwar avatar Oct 05 '15 10:10 chyzwar

I noticed that Clear All Filters option always has id="menuitem-0", if you want remove that option, you can do this in css:

#menuitem-0{
    display: none;
}

thorvx avatar Apr 07 '16 16:04 thorvx

You have to wrap it in a timeout or something. Looks like even if after the gridApi has loaded it still needs to wait for the other components.

http://ui-grid.info/docs/#/tutorial/121_grid_menu

      // interval of zero just to allow the directive to have initialized
      $interval( function() {
        gridApi.core.addToGridMenu( gridApi.grid, [{ title: 'Dynamic item', order: 100}]);
      }, 0, 1);

tbaeg avatar Apr 20 '16 20:04 tbaeg