Posted 30 March 2020, 7:12 pm EST
export default class CustomContextMenuView extends GC.Spread.Sheets.ContextMenu.MenuView {
public customMenuData = [
{
text: ‘merge cells’,
name: ‘gc.spread.customContextMenu.merge’,
command: this.handleCustomCommand,
workArea: ‘viewportcorner’
}
]
constructor() {
super()
}
createMenuItemElement(menuItemData: GC.Spread.Sheets.ContextMenu.IMenuItemData): HTMLElement {
const menuElement = super.createMenuItemElement(menuItemData)
return menuElement
}
getCommandOptions(menuItemData: GC.Spread.Sheets.ContextMenu.IMenuItemData, host: Record<string, any>, event: Record<string, any>): any {
const name = menuItemData.name || ‘’
if (name.indexOf(‘customContextMenu’) > -1) {
return { menuItemData, host, event }
} else {
super.getCommandOptions(menuItemData, host, event)
}
}
handleCustomCommand(context: GC.Spread.Sheets.Workbook, options: any) {
const name = options.menuItemData.name
const activeSheet = context.getActiveSheet()
const selections = activeSheet.getSelections()
switch (name) {
case ‘gc.spread.customContextMenu.merge’:
if (selections.length === 1) {
const { row, col, rowCount, colCount } = selections[0]
activeSheet.addSpan(row, col, rowCount, colCount, GC.Spread.Sheets.SheetArea.viewport)
}
break
}
}
spreadsheet how to bind mergeChanged event,there is not event type