New to Kendo UI for AngularStart a free 30-day trial

Preventing Formula Input in the Spreadsheet

Environment

ProductProgress® Kendo UI® Spreadsheet for Angular

Description

I want to prevent users from entering formulas into the cells of the Kendo UI for Angular Spreadsheet component. How can I achieve this?

This Knowledge Base article also answers the following questions:

  • How to prevent formula input in the Kendo UI for Angular Spreadsheet?
  • How to block the = key in Angular Spreadsheet cells?
  • How to restrict users from entering formulas in the Kendo UI for Angular Spreadsheet?

Solution

To prevent users from entering formulas into the cells of the Spreadsheet:

  1. Bind the changing event of the SpreadsheetWidget after the view initializes.

    ts
    ngAfterViewInit() {
        setTimeout(() => {
            this.spreadsheet.spreadsheetWidget.bind('changing', this.onChanging);
        }, 100);
    }
  2. Use the event arguments to check if the user input starts with = and prevent the event.

    ts
    private onChanging(args) {
        const data = args.data;
    
        if (data[0] === '=') {
          args.preventDefault();
          alert('Formulas are not allowed');
        }
    }

The following example demonstrates the suggested approach in action.

Change Theme
Theme
Loading ...
In this article
EnvironmentDescriptionSolutionSuggested Links
Not finding the help you need?
Contact Support