Add JSON serialization of datagrids.
Review Request #14819 — Created Feb. 16, 2026 and updated
Datagrids can now be serialized to JSON, providing information on active
and available columns, pagination, sorting information, rows, and each
cell within. The cells contain both rendered HTML (the<td>and
everything inside) and a JSON value for processing.This can be used to provide datagrid functionality in other contexts.
The primary purpose at this time is to enable API access to datagrids.
The information can be returned as-is or further processed to provide
a more integrated response into an API response format.Columns can provide an explicit JSON value alongside rendered HTML. Both
now default to making use of a newget_raw_object_value(), which can
provide a suitable value from an object. This is intended for column
implementations to override and use as necessary, and to simplify common
code used forrender_data()andto_json().
Unit tests pass.
| Summary | ID |
|---|---|
| 11740c0c81165439a08fa74dd2a505c34a7efab0 |
| Description | From | Last Updated |
|---|---|---|
|
Should probably be "... in a datagrid." instead of "... in a datagrid row." |
|
|
|
Can we add "or None if this column has no field_name." here too. |
|
|
|
Given that this implementation types the return value as datetime | None, seems like this could say it returns datetime.datetime. |
|
|
|
Other implementations of this use "Return a JSON-serializable value for an object in a cell" for the description. Looks like … |
|
|
|
Shouldn't this be using self.get_raw_object_value(obj)? Let's also call the variable something other than datetime so we don't shadow the import. |
|
|
|
You can use stateful_columns here instead of self.columns. |
|
|
|
Please fix the docstring to say "... with no field name" |
|
-
-
-
Given that this implementation types the return value as
datetime | None, seems like this could say it returnsdatetime.datetime. -
Other implementations of this use "Return a JSON-serializable value for an object in a cell" for the description. Looks like this was missed as you iterated.
-
Shouldn't this be using
self.get_raw_object_value(obj)?Let's also call the variable something other than
datetimeso we don't shadow the import. -
- Change Summary:
-
- Fixed a handful of docs and docstrings.
- Updated
DateTimeSinceColumnto utilizeget_raw_object_value(), and fixed a variable name conflict. - Updated a reference to
self.columnsto just use the local variable we already pulled out.
- Commits:
-
Summary ID 3fbcb7f5fd9f71ed1c49e2acb314f30950c8121b 11740c0c81165439a08fa74dd2a505c34a7efab0 - Diff:
-
Revision 2 (+1480 -56)