Data Validation

SpreadSheet Grid supports the following cell level data Validation

  1. List (static)
  2. Checkbox
  3. Decimal
  4. List (formula range) - Coming soon
  5. Date - Coming soon

List (static)

const sheets = [
{
name: "Sheet 1",
id: 0,
cells: {
2: {
2: {
text: "",
valid: false,
dataValidation: {
prompt: "Enter a country",
type: 'list',
formulae: ['Singapore', 'Japan', 'China']
},
},
},
},
},
];
<Spreadsheet initialSheets={sheets} />

Demo

fx

Sheet 1

Checkbox

Checkbox validation schema is as per below

const initialValidationSheet: Sheet[] = [
{
name: "Sheet 1",
id: 0,
activeCell: null,
selections: [],
cells: {
4: {
2: {
text: 'TRUE',
datatype: 'boolean',
dataValidation: {
allowBlank: true,
type: "boolean",
formulae: ["TRUE", "FALSE"]
}
}
}
}
}
];

Demo

fx

Sheet 1

Decimal

Validation for decimals number can be added using this schema

const initialValidationSheet: Sheet[] = [
{
name: "Sheet 1",
id: 0,
activeCell: null,
selections: [],
cells: {
4: {
2: {
text: '',
dataValidation: {
allowBlank: true,
type: "decimal",
operator: 'between',
prompt: 'Enter a decimal between 0 and 10',
formulae: [0, 10]
}
}
}
}
}
];
note

Supported operators

export type DataValidationOperator =
| "between"
| "notBetween"
| "equal"
| "notEqual"
| "greaterThan"
| "lessThan"
| "greaterThanOrEqual"
| "lessThanOrEqual";