Skip to content

Validator extension with Angular not working #30

@gcfalck

Description

@gcfalck

I'm trying to use the validation extension with an angular project. I've updated my license key to include Validations. I include the validation npm package and set the extension but when I go to execute the code, it says the worksheet object is valid but setValidations is undefined.
The runtime error is: ERROR TypeError: worksheet.setValidations is not a function.
I see in the index.d.ts file, setValidations should be on the worksheetInstance object.

How do I get Validations to work with jSpreadsheet in Angular?

Thanks, Greg

Sample code below

        import { validations } from '@jspreadsheet/validations';
        import * as jspreadsheet from 'jspreadsheet';
        jspreadsheet.setLicense('xxxxxx');
        // Set the extensions
        jspreadsheet.setExtensions({ validations });
        this.jss= jspreadsheet(nativeElement, { ... });

        function onBeforePaste(worksheet, data, x, y, style, processedData) {

            // if some condition - call setValidators(worksheet);

            function setValidators(worksheet: jspreadsheet.worksheetInstance) {
                // if some condition is met
                worksheet.setValidations([{
                    index: 0,
                    value: {
                        range: 'A3',
                        action: 'warning',
                        criteria: '!=',
                        type: 'text',
                        allowBlank: false,
                        value: ['xxxxRandomStringyyyy'],
                        text: 'You have an error!'
                    }
                }]);
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions