Last active
June 6, 2019 09:37
-
-
Save Narshe1412/da0df6399bf259bd2abfeb8c50465938 to your computer and use it in GitHub Desktop.
SpreadJS: Implement Alt+Down key for List Validator Dropdowns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const commandManager = workbook.commandManager(); | |
commandManager.register('showListDown', () => openDropdown(sheet, workbook)); | |
commandManager.setShortcutKey('showListDown', GC.Spread.Commands.Key.down, false, false, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as GC from '@grapecity/spread-sheets'; | |
export const openDropdown = (sheet: GC.Spread.Sheets.Worksheet, workbook: GC.Spread.Sheets.Workbook) => { | |
const row = sheet.getActiveRowIndex(); | |
const col = sheet.getActiveColumnIndex(); | |
const validator = sheet.getCell(row, col).validator(); | |
if (validator) { | |
// if cell has data validator, show the list. | |
const inputElement = workbook.getHost().getElementsByTagName('input')[0]; | |
if (inputElement) { | |
inputElement.click(); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adapted from the code provided by Grapecity here: https://stackoverflow.com/a/55971587/5866637