Skip to main content

Setting a schema

Schema is optional. Schema is an array of header objects. This documentation will use the term header and column interchangeably. If no schema is provided one will be generated from the data, in that case all data will be assumed to be string data.

Note: When data is generated from an 2D array (array of arrays vs. array of objects) the columns will be named A, B, C, D,... etc..

Each header object can have the following properties:

PropertyDescription
nameThe name of the column. This is used to match with data and is the only required property.
typeThe data type of this column
titleWhat will be displayed to the user. If not present, name will be used.
widthThe default width in pixels of this column.
hiddenWhen true the column will be hidden.
filterThe filter function to use to filter this column. If no function is provided, type will determine filer.
formatterThe formatter function used display this column. If no function is provided, type will determine formatter.
defaultValueThe default value of this column for new rows. This is a function or a string. When a function is used, it takes the arguments header and index and must return a value for new default cell value in this column.

Example schema:

[
{
name: 'col1',
},
{
name: 'col2',
},
{
name: 'col3',
},
];