New to Kendo UI for Angular? Start a free 30-day trial
Preventing Formula Input in the Spreadsheet
Environment
Product | Progress® 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:
-
Bind the
changing
event of theSpreadsheetWidget
after the view initializes.tsngAfterViewInit() { setTimeout(() => { this.spreadsheet.spreadsheetWidget.bind('changing', this.onChanging); }, 100); }
-
Use the event arguments to check if the user input starts with
=
and prevent the event.tsprivate 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 ...