How can I show the "Find and Replace" dialog programmatically?

Posted by: fetbi.irsat on 13 February 2025, 5:01 pm EST

    • Post Options:
    • Link

    Posted 13 February 2025, 5:01 pm EST

    As the title suggest I’d like to show the “Find and Replace” dialog from a button click or from a Ctrl + F outside of the context of the spreadsheet.

    Note: I am using SpreadJs v17

  • Posted 14 February 2025, 3:32 am EST

    Hi,

    It is possible to open the Find and Replace dialog from a button click or pressing the shortcut key - “Ctrl + F” from outside the context of Spreadsheets by executing the command FindDialogFind: https://developer.mescius.com/spreadjs/api/designer/classes/GC.Spread.Sheets.Designer.CommandNames#finddialogfind when the button is clicked or the shortcut keys are pressed. Please refer to the code snippet below that illustrates the same.

    const command = GC.Spread.Sheets.Designer.getCommand(
      GC.Spread.Sheets.Designer.CommandNames.FindDialogFind
    );
    
    function executeFindDialogCommand() {
      command.execute(designer);
    }
    
    externalButton.addEventListener("click", function (event) {
      executeFindDialogCommand();
    });
    
    document.addEventListener("keydown", function (event) {
      if (event.ctrlKey && event.key.toLowerCase() === "f") {
        event.preventDefault();
        executeFindDialogCommand();
      }
    });

    You can further refer to the attached code snippet which uses the above code snippet and opens the find dialog as required (see below).

    Please feel free to reach out if you encounter any further issues or require additional guidance.

    Attachment: Sample.zip

    Best Regards,

Need extra support?

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

Learn More

Forum Channels