A Primary Key is required by AdapTable for cell identification purposes.
If the showMissingPrimaryKeyWarning property is true in General Options (the default value), AdapTable will warn at start-up if there is no column in the grid which matches the provided value.
Primary Key Column
The Primary Key is set via the (mandatory)
primaryKey property in Base Adaptable Options.
The value should be the Id of a column in the grid's data source.
The column does not need to be visible but it does need to exist in the grid's data source.
It is important that Primary Key Column is one which guarantees to contain unique values.
At the moment it is not possible to provide a composite key of more than one column but this might be available in future versions of AdapTable
Auto Generated Key
If it is absolutely not possible to provide a Primary Key column of your own, AdapTable can auto-generate one.
Only use this option if it is a last resort and there is no column with unique values
autogeneratePrimaryKey property to true in Adaptable Options and AdapTable will create - and manage - its own internal Primary Key.
There are a few limitations which you need to be aware of, if using an auto generated Primary Key:
The Free Text Column Module is not available as it requires persistable Primary Key values
Live Data updates from Excel back to AdapTable (when using OpenFin) will not work (as Excel needs the column to be in the exported data)
The only way to handle providing and updating grid data is through AdapTable's Grid Api. So you must use the following methods for any data manipulation you require:
This restriction is required because AdapTable needs to intercept all data-related methods in order to ensure Primary Keys are propertly created and then kept correctly updated
loadGridDatafor initial data load
addGridDatato add new columns to the Grid
updateGridDatato edit / update rows at run-time
To use an auto generated Primary Key requires a few changes in your AdapTable setup.
This is a truncated version of the code in our Getting Started page but with an auto generated Primary Key: