Skip to content

Commit

Permalink
fix(plugin): Grid Menu shouldn't be displayed in preheader by default (
Browse files Browse the repository at this point in the history
…#1523)

- add `iconButtonContainer: 'preheader' | 'header'` grid option (default to 'header'). For example, the Grid Menu is shown in the Draggable Grouping drop zone but it should really be in the Column Header section, we'll change the default to 'header' but let's add a grid option to let the user choose either 'preheader' or 'header'
  • Loading branch information
ghiscoding authored May 11, 2024
1 parent dc5d402 commit 7e0cdc9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions examples/vite-demo-vanilla-bundle/src/examples/example08.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export default class Example08 {
exportWithFormatter: true,
sanitizeDataExport: true
},
gridMenu: {
iconButtonContainer: 'preheader' // we can display the grid menu icon in either the preheader or in the column header (default)
},
externalResources: [new TextExportService(), new ExcelExportService()],
enableCellNavigation: true,
enableColumnReorder: false,
Expand Down
4 changes: 3 additions & 1 deletion packages/common/src/extensions/slickGridMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ export class SlickGridMenu extends MenuBaseClass<GridMenu> {
if (this._addonOptions?.iconCssClass) {
this._gridMenuButtonElm.classList.add(...classNameToList(this._addonOptions.iconCssClass));
}
this._headerElm.parentElement!.insertBefore(this._gridMenuButtonElm, this._headerElm.parentElement!.firstChild);
// add the grid menu button in the preheader (when exists) or always in the column header (default)
const buttonContainerTarget = this._addonOptions.iconButtonContainer === 'preheader' ? 'firstChild' : 'lastChild';
this._headerElm.parentElement!.insertBefore(this._gridMenuButtonElm, this._headerElm.parentElement![buttonContainerTarget]);

// show the Grid Menu when hamburger menu is clicked
this._bindEventService.bind(this._gridMenuButtonElm, 'click', this.showGridMenu.bind(this) as EventListener);
Expand Down
5 changes: 4 additions & 1 deletion packages/common/src/interfaces/gridMenuOption.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ export interface GridMenuOption {
/** Defaults to true, which will hide the "Toggle Pre-Header Row" (used by draggable grouping) command in the Grid Menu (Grid Option "showPreHeaderPanel: true" has to be enabled) */
hideTogglePreHeaderCommand?: boolean;

/** CSS class for the displaying the Grid menu icon (basically the hamburger menu) */
/** Defaults to "header", where should we display the grid menu button? Should it be inside the "preheader" (when exists) or always inside the column "header" (default). */
iconButtonContainer?: 'preheader' | 'header';

/** CSS class for the displaying the Grid menu icon (aka the hamburger menu button) */
iconCssClass?: string;

/** icon for the "Clear all Filters" command */
Expand Down

0 comments on commit 7e0cdc9

Please sign in to comment.