Hello,
I am working with the spreadsheet control. I have added several custom items to the context menu as well as using some of the built in items. However, when there is just one tab in the spreadsheet some of the items are disabled when they should be enabled. When there are multiple tabs all the items are enabled. I have not been able to figure out why this is happening. Below is the code where I add the custom items.
function contextMenuBeforeOpen(args) {
if (args.element.ej2_instances[0].items.length == 5) {
var index = this.activeSheetIndex;
selectedVersion = versionArray[index].versionNumber;
var enabled = versionArray[index].enabled;
// Adds Context menu item "Rule Conditions"
this.addContextMenuItems([{ text: "Rule Conditions" }], "Delete", false);
this.addContextMenuItems([{ text: "Edit Columns" }], "Delete", false);
this.addContextMenuItems([{ text: "Edit Table Info" }], "Edit Columns", false);
if (enabled == false) {
this.addContextMenuItems([{ text: "Enable" }], "Delete", false);
}
else {
this.addContextMenuItems([{ text: "Disable" }], "Delete", false);
}
this.removeContextMenuItems(['Rename'], false, false);
this.removeContextMenuItems(['Hide'], false, false);
this.removeContextMenuItems(['Protect Sheet'], false, false);
this.removeContextMenuItems(['Insert'], false, false);
}
else {
this.addContextMenuItems([{ text: "Row Rule Conditions" }], "Insert Row", false);
// Disables Insert Row In context Menu
this.enableContextMenuItems(['Insert Row'], false, false);
this.removeContextMenuItems(['Hide Row'], false, false);
}
}
Thanks,
Dana
Hello,
I am using https://cdn.syncfusion.com/ej2/19.1.63/dist/ej2.min.js
As shown in the clip if I have a spreadsheet that only has on tab, two of the items in the menu are shaded and disabled when they should be active. However, if there is more than one tab within the spreadsheet then all of the items are active and able to be clicked.
I have attached a zip file that contains a screen record of the issue I am having.
Thanks,
Dana
|
<ejs-spreadsheet id="spreadsheet" contextMenuBeforeOpen="createdHandler">
<e-spreadsheet-sheets>
<e-spreadsheet-sheet>
<e-spreadsheet-ranges>
<e-spreadsheet-range dataSource="ViewBag.DefaultData"></e-spreadsheet-range>
</e-spreadsheet-ranges>
<e-spreadsheet-columns>
<e-spreadsheet-column width="80"></e-spreadsheet-column>
<e-spreadsheet-column width="80"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="80"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
<e-spreadsheet-column width="100"></e-spreadsheet-column>
</e-spreadsheet-columns>
</e-spreadsheet-sheet>
</e-spreadsheet-sheets>
</ejs-spreadsheet>
<script>
function createdHandler(args) {
this.addContextMenuItems([{ text: "Row Rule Conditions" }], "Insert", false);
// Disables Insert Row In context Menu
this.enableContextMenuItems(['Row Rule Conditions'], false, false);
this.removeContextMenuItems(['Hide'], false, false);
this.removeContextMenuItems(['Rename'], false, false);
this.removeContextMenuItems(['Protect Sheet'], false, false);
this.removeContextMenuItems(['Insert'], false, false);
}
</script> |
Hello,
Thank you for your reply. Unfortunately it doesn't solve the problem. I have replicated the issue in the file you sent and I also created a video demo to show you where I am having the issue. The items on the context menu that are disabled (or in this example the item enable, not the default ones) when there is a single version I need enabled at all times. The user needs to be able to click on them.
Thanks,
Dana
|
<script>
function createdHandler(args) {
this.removeContextMenuItems(
['Hide', 'Rename', 'Protect Sheet', 'Insert'],
false
);
this.addContextMenuItems(
[{ text: 'Row Rule Conditions' }],
'Duplicate',
false,
false
);
this.addContextMenuItems(
[{ text: 'Enable', id: 'enable' }],
'Row Rule Conditions',
false,
false
);
this.addContextMenuItems(
[{ text: 'Edit Columns', id: 'Tobeshown' }],
'Duplicate',
true,
false
);
}
</script>
<style>
#enable,#Tobeshown {
color: black !important;
cursor: pointer !important;
pointer-events: auto !important;
}
</style> |