Disable hide functions

Posted by: jeff on 11 November 2020, 4:08 am EST

    • Post Options:
    • Link

    Posted 11 November 2020, 4:08 am EST

    I want to remove certain functions from the autocomplete when a user begins editing a cell inside a table. I still want those functions to be available on the rest of the sheet. I also want them to no be visible in autocomplete.

    Is it possible the disable and reenable functions?

    Can you place provide an example snippet.

  • Posted 12 November 2020, 8:27 am EST

    Hi Jeff,

    If I understand correctly you want to disable the suggestion dialogbox.For this, you may use the enableFormulaTextbox option and EditStarting Event and disable option for the particular cell. Please refer to the following code snippet and the attached sample and let us know if you face any issues.

    
    sheet.bind(GC.Spread.Sheets.Events.EditStarting, (e, args) => {
        if (args.col === 0) {
          spread.options.enableFormulaTextbox = false;
        } else {
          spread.options.enableFormulaTextbox = true;
        }
      });
    
    

    sample: https://codesandbox.io/s/brave-sanderson-fln26?file=/src/index.js:214-429

    Regards

    Avinash

  • Posted 12 November 2020, 2:58 pm EST

    Avinash,

    Not quite. I want to “remove certain functions” from the formulaTextbox. I do not want disable it. I only want a limited set of functions to be available [SUM, AVERAGE, CONCAT]. Can I remove functions from the autocomplete/dropdown? Can I add the functions back?

  • Posted 17 November 2020, 12:37 am EST

    Hi Jeff,

    Sorry for the delayed response. We are unable to achieve the required functionality using the current public API hence we have escalated this issue to our devs. We will update you regarding this as soon as get any information from the Devs. The internal ID for this issue will be SJS-6502.

    Regards

    Avinash

  • Posted 19 November 2020, 11:08 pm EST

    Hi Jeff,

    SpreadJS does not support this feature natively… But you may override FormulaTexbox.add method for the required functionality. Please refer to the following code snippet and let us know if you face any issues.

    var addFn = GC.Spread.Sheets.FormulaTextBox.FormulaTextBox.prototype.add;
    GC.Spread.Sheets.FormulaTextBox.FormulaTextBox.prototype.add = function (functions) {
        var temp = [], spread = GC.Spread.Sheets.findControl("ss"), sheet = spread.getActiveSheet();
        var activeRowIndex = sheet.getActiveRowIndex(), activeColIndex = sheet.getActiveColumnIndex();
        functions.forEach(function (fn) {
    //Sum is disabled for Cell (0,0)
            if (fn.name === "SUM" && activeRowIndex === 0 && activeColIndex === 0) {
                return;
            }
            temp.push(fn);
        })
        addFn.apply(this, [temp]);
    }
    window.onload = function () {
        var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 4 });
    };
     
    

    Regards

    Avinash

Need extra support?

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

Learn More

Forum Channels