DataTables warning: table id=… - Requested unknown parameter 'date' for row 0 & time‑zone support
0 reputation · 21 Nov 2020, 15:18 UTC
0 reputation · 21 Nov 2020, 15:18 UTC
When a DataTable is initialized with a column that references a field not present in the row data, the library emits the error “DataTables warning: table id=… - Requested unknown parameter 'date' for row 0”. This warning indicates that the column’s data source is missing at initialization time.
The DataTables dateTime plug‑in can sort ISO‑8601 strings, but it treats them as UTC. Without explicit conversion, the displayed times remain in UTC and sorting may produce misleading results for users in other time zones.
Should DataTables implement native time‑zone conversion for date columns, or continue to rely on external libraries such as moment.js or custom render functions?
34775 reputation · 21 Nov 2020, 18:07 UTC
The message DataTables warning: table id=… - Requested unknown parameter 'date' for row 0 is emitted when a column definition uses { data: 'date' } (or mData) but the JSON/AJAX payload for the first row does not contain a property named exactly date. DataTables tries to read that property before any rendering or formatting runs, so a missing field triggers the warning immediately.
Date or timestamp will not satisfy data: 'date'.undefined the formatter cannot run and the warning is shown first.defaultContent hides the warning but does not fix the underlying data mismatch.timestamp, createdAt, eventDate).{
data: 'timestamp', // replace with the actual property name
title: 'Date',
render: function (value) {
// optional formatting – see timezone section below
return value ? new Date(value).toLocaleString() : '';
}
}
date field, you may keep the column definition and add defaultContent: '' as a temporary fallback, but verify that missing dates are intentional.The dateTime plug‑in sorts ISO‑8601 strings correctly, but it treats them as UTC. Consequently:
timezone: 'America/New_York' or utcOffset would increase the number of column‑level settings and require documentation, versioning, and backward‑compatibility checks.deferRender.Keep the existing dateTime plug‑in for sorting (it works on the raw ISO string) and handle localisation in a column render function using a lightweight library such as Luxon or the built‑in Intl.DateTimeFormat. This approach:
data property, open the console and confirm no warning appears.Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 22 Nov 2020, 01:39 UTC
DataTables 1.10+ auto-detects ISO-8601 strings for sorting but compares them as UTC strings. No native time-zone conversion is performed by the core or the legacy dateTime plug-in.
A stable pattern is orthogonal data: keep the raw ISO string in the data source for correct chronological sort, and use columns.render with a type check to return the ISO value for sort and a localized string for display. The sort algorithm then stays on UTC values while the UI shows local time.
With serverSide: true any zone conversion must be done server-side; the client only sorts the strings it receives.