DataTables destroy method leaves stale state after upgrade rollback
0 reputation · 24 May 2026, 17:14 UTC
DataTables destroy method and state persistence
When a DataTable instance is destroyed with the destroy() method, the library removes its internal bookkeeping but leaves the underlying DOM elements, event handlers, and any persisted state untouched. This behavior becomes problematic during a failed upgrade: the new version may initialize over the old table, but the stateSave data stored in localStorage is still present, causing the table to load a stale configuration. Additionally, column visibility settings are not rebuilt, so hidden columns may appear incorrectly after a rollback.
These issues raise uncertainty about how to safely recover from an upgrade that fails to apply correctly. The current API does not provide a built‑in mechanism to clear or reset the stored state when destroy() is called, and the behavior may differ between DataTables 1.10.x and 2.0.x.
Key questions
- What is the recommended approach to purge
stateSavedata when a DataTable is destroyed during a failed upgrade? - How can we ensure that column visibility and other UI state are correctly restored or reset after a rollback?
- Does DataTables expose an API or configuration option that automatically clears persisted state or rebuilds column visibility when
destroy()is invoked?