Validation on basis of two dependent columns

Tags: #<Tag:0x00007efc608c0128>

I have a table like this


what i want here is that if any of total amount(local currency) or total amount (foreign currency) is provided then consider it as valid row but both are not given then mark total amount(local currency) as invalid is it possible to achieve scenario like this.
i am using 11.0.1 version of handsontable in angular application

settings: Handsontable.GridSettings = {
    width: '100%',
    manualRowResize: true,
    manualColumnResize: true,
    allowRemoveColumn: false,
    allowInsertRow: true,
    startRows: 5,
    rowHeaders: true,
    height: 'auto',
    licenseKey: 'non-commercial-and-evaluation',
    allowRemoveRow: true,
    outsideClickDeselects: false,
    stretchH: 'all', // 'none' is default
    contextMenu: true,
    columns: [
        {
            data: 'date', correctFormat: true, dateFormat,
            placeholder: dateFormat, type: 'date', allowInvalid: true,  title: 'Date'
        },
        {
            data: 'description', type: 'text', title: 'Description', placeholder: 'Vendor'
        },
        {
            data: 'total_amount', type: 'text' , allowInvalid: true, placeholder: '1.25/1,25', title: 'Amount (Local Currency)',
            validator: (value: CellValue, callback: (valid: boolean) => void) => {
                return somevalidator(props, value, callback);
            }
        },
        {
            data: 'foreign_amount', placeholder: '1.25 USD/1,25 USD', type: 'text', allowInvalid: true, title: 'Amount (Foreign Currency)',
            validator: (value: CellValue, callback: (valid: boolean) => void) => {
                return somevalidator(props, value, callback);
            },
        },
        {
            data: 'exchange_rate', type: 'text', allowInvalid: true,  placeholder: '1.25/1,25', title: 'Exchange Rate',
            validator: ((value: CellValue, callback: (valid: boolean) => void) => {
                return somevalidator(props, value, callback);
            })
        },
    ],
};

@aleksandra_budnik @adrian.szymanski need your help guys :slight_smile:

Hi @talhach891

We’ll check your issue and get back to you soon.

Hi @talhach891

You can achieve something like this using setCellMeta with valid value and set it to false.

Here’s an example: http://jsfiddle.net/n5x4rnwf/

1 Like