F2 key binding

Posted by: davide.vago on 29 September 2019, 9:48 pm EST

  • Posted 29 September 2019, 9:48 pm EST

    Good morning/afternoon

    I'm writing in regards of the blog post:
    https://www.grapecity.com/blogs/no-f2-key-in-spreadjs

    It seems like the given snippet doesn't work as the mentioned function doesn't exists on the activeSheet instance, I've commented the post few days ago but I guess this is the right channel to address the problem.

    Looking forward to hearing from you.
  • Replied 30 September 2019, 4:09 pm EST

    Hi Davide,

    The blog post refers to an older version of SpreadJs. In the current version(v12), we need to register our custom commands using the commandManager.register() method. Please refer to the following code snippet and the sample demonstrating the same:
    function registerCustomCommands(spread) {
    var commandManager = spread.commandManager();
    var editOnF2Command = {
    canUndo: false,
    execute: function(wbContext, options, isUndo) {
    var sheet = wbContext.getSheetFromName(options.sheetName);
    if (sheet) {
    sheet.startEdit();
    }
    return true;
    }
    };

    commandManager.register(
    "editOnF2Command",
    editOnF2Command,
    113, // key code for F2
    false,
    false,
    false,
    false
    );
    }

    https://codesandbox.io/s/spread-js-starter-jgutp

    API reference:
    • register method: http://help.grapecity.com/spread/SpreadSheets12/webframe.html#SpreadJS~GC.Spread.Commands.CommandManager~register.html

    For any query or issues related to Spread.Sheets, please use the following support forum dedicated to Spread.Sheets discussions:
    https://www.grapecity.com/forums/spread-sheets

    Regards
    Sharad
  • Replied 30 September 2019, 10:07 pm EST

    Thanks Sharad,

    This solved my issue. I would suggest to place somewhere the referred version on the blog post so people don't get confused.
  • Replied 2 October 2019, 6:04 pm EST

    Thank you for the suggestion. We have asked the concerned team to look into it(Internal tracking ID: SJS-1952)
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels