The previous article discussed adding customized actions while retaining predefined items.
However, it did not cover renaming or adding hidden/disable functions to the predefine menu items.
I attempted to keep the original callback function and rewrite name/disable/hidden, but encountered issues.
Could you please provide assistance?
demo:https://jsfiddle.net/khcojfLg/2/
Rename the default name of remove_row and disable it in the first row.
However, after that, the click action is malfunctioning.
contextMenu: {
callback(key, selection, clickEvent) {
// Common callback for all options
console.log(key, selection, clickEvent);
},
items: {
row_above: {
name() { // `name` can be a string or a function
return '<b>Custom row adding</b>';
},
disabled() {
// Disable option when first row was clicked
return this.getSelectedLast()[0] === 0; // `this` === hot
},
hidden() {
// Hide the option when the first column was clicked
return this.getSelectedLast()[1] == 0; // `this` === hot
},
}
}
}
Based on the previous reply, it appears that we cannot set items with an object data type when attempting to add an menu item associated with the nestedRow plugin.
Therefore, you provided another solution defining items as an array. However, in this array-based solution, I’m unsure how to keep the original operaiton (callback function) and set the name/disabled function as an object type solution.