From fc5f297977294d1206e236a709390061497b8076 Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Wed, 8 Sep 2021 20:30:11 -0400 Subject: [PATCH] fix: few minor fixes on plugin with menus - make sure commands/options are defined and also allow `false` to work as it should - also make the cellMenu/contextMenu work with just options set (without any commands) --- controls/slick.gridmenu.js | 6 +++--- plugins/slick.cellmenu.js | 6 +++--- plugins/slick.contextmenu.js | 6 +++--- plugins/slick.headermenu.js | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/controls/slick.gridmenu.js b/controls/slick.gridmenu.js index a7095c2d..220f04a7 100644 --- a/controls/slick.gridmenu.js +++ b/controls/slick.gridmenu.js @@ -157,8 +157,8 @@ } }; - // when a grid changes from a regular grid to a frozen grid, we need to destroy & recreate the grid menu - // we do this change because the Grid Menu is on the left container on a regular grid but is on the right container on a frozen grid + // when a grid optionally changes from a regular grid to a frozen grid, we need to destroy & recreate the grid menu + // we do this change because the Grid Menu is on the left container for a regular grid, it is however on the right container for a frozen grid grid.onSetOptions.subscribe(function (e, args) { if (args && args.optionsBefore && args.optionsAfter) { var switchedFromRegularToFrozen = args.optionsBefore.frozenColumn >= 0 && args.optionsAfter.frozenColumn === -1; @@ -304,7 +304,7 @@ } var $li = $("
") - .data("command", item.command || '') + .data("command", item.command !== undefined ? item.command : "") .data("item", item) .on("click", handleMenuItemClick) .appendTo($customMenu); diff --git a/plugins/slick.cellmenu.js b/plugins/slick.cellmenu.js index 374d504c..6dd28b21 100644 --- a/plugins/slick.cellmenu.js +++ b/plugins/slick.cellmenu.js @@ -193,7 +193,7 @@ var optionItems = _cellMenuProperties.optionItems || []; // make sure there's at least something to show before creating the Cell Menu - if (!columnDef || !columnDef.cellMenu || (!commandItems.length && optionItems.length)) { + if (!columnDef || !columnDef.cellMenu || (!commandItems.length && !optionItems.length)) { return; } @@ -459,7 +459,7 @@ } var $li = $('
') - .data("option", item.option || "") + .data("option", item.option !== undefined ? item.option : "") .data("item", item) .on("click", handleMenuItemOptionClick) .appendTo(optionMenuElm); @@ -539,7 +539,7 @@ } var $li = $('
') - .data("command", item.command || "") + .data("command", item.command !== undefined ? item.command : "") .data("item", item) .on("click", handleMenuItemCommandClick) .appendTo(commandMenuElm); diff --git a/plugins/slick.contextmenu.js b/plugins/slick.contextmenu.js index 4cbf8998..35858a91 100644 --- a/plugins/slick.contextmenu.js +++ b/plugins/slick.contextmenu.js @@ -212,7 +212,7 @@ var optionItems = _contextMenuProperties.optionItems || []; // make sure there's at least something to show before creating the Context Menu - if (!columnDef || (!isColumnCommandAllowed && !isColumnOptionAllowed) || (!commandItems.length && optionItems.length)) { + if (!columnDef || (!isColumnCommandAllowed && !isColumnOptionAllowed) || (!commandItems.length && !optionItems.length)) { return; } @@ -415,7 +415,7 @@ } var $li = $('
') - .data("option", item.option || "") + .data("option", item.option !== undefined ? item.option : "") .data("item", item) .on("click", handleMenuItemOptionClick) .appendTo(optionMenuElm); @@ -495,7 +495,7 @@ } var $li = $('
') - .data("command", item.command || "") + .data("command", item.command !== undefined ? item.command : "") .data("item", item) .on("click", handleMenuItemCommandClick) .appendTo(commandMenuElm); diff --git a/plugins/slick.headermenu.js b/plugins/slick.headermenu.js index 14018536..9dfbb0dd 100644 --- a/plugins/slick.headermenu.js +++ b/plugins/slick.headermenu.js @@ -245,7 +245,7 @@ } var $li = $("
") - .data("command", item.command || '') + .data("command", item.command !== undefined ? item.command : "") .data("column", columnDef) .data("item", item) .on("click", handleMenuItemClick)