Disable hide functions

Posted by: jeff on 10 November 2020, 7:08 pm EST

  • Posted 10 November 2020, 7:08 pm 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.
  • Replied 11 November 2020, 11:27 pm 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
  • Replied 12 November 2020, 5:58 am 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?
  • Replied 16 November 2020, 3:37 pm 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
  • Replied 19 November 2020, 2: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