Here is my approach to solving the issue at hand.
Customizing CSS to Conceal the Original Button
In order to hide the original button and reposition the menu in the top-right corner, I carefully explained the purpose of each line in the comments within the code snippet below. Ensuring that the grid menu is displayed exactly where I want it can be a bit tricky, especially if you prefer it in a different corner of the table.
.ui-grid-menu-button {
border: none; // hiding the button
background: transparent; // removing button background
}
.ui-grid-menu-button .ui-grid-icon-container {
visibility: hidden; // concealing the icon
height: 0; // adjusting for top-right corner placement
margin-top: 0; // aligning with top corner
}
Implementing a Custom Button in HTML
<div
ng-if="myUiGridOptions.enableGridMenu"
ng-click="gridApi.grid.gridMenuScope.toggleMenu()">
<!-- icon for the menu -->
</div>
The gridApi
variable serves as the interface for ui-grid and can be accessed like this:
myUiGridOptions.onRegisterApi = function (gridApi) => {
$scope.gridApi = gridApi;
};
The Final Outcome
https://i.sstatic.net/ClnPu.png
https://i.sstatic.net/BxsYI.png