Add constructor-level customization of columns and sorting in datagrids.
Review Request #14818 — Created Feb. 16, 2026 and updated
Datagrids have historically allowed for custom column selection/ordering
and sorting via HTTP GET query strings. This works great in the case
where you want to display a standard datagrid page with user choices,
but less so when you want to handle providing these options through
other means.This change introduces new
columnsandsortarguments to the
DataGridconstructor. These both take lists of strings, and behave the
same way that the query string versions do. They can also takeNone,
which will force usage of the datagrid defaults.This not only overrides (and disables) anything in the querystring, but
also prevents both loading from and saving to the user profile.
Unit tests pass.
Tested with some in-progress code using specially-constructed datagrids,
and verified I could define the columns and sort order.
| Summary | ID |
|---|---|
| b60b8f39ff477c8b6cc122ce62163fdf63aa25c1 |
| Description | From | Last Updated |
|---|---|---|
|
In the change description, you say a None value forces usage of the datagrid defaults. Can we add unit tests … |
|
|
|
These were wrong previously, but both should be typed as str | None. |
|
|
|
Since you removed the part of the docstring about returning bool, can we update this to just return list[str]? |
|
|
|
We could take all of this out of the if sort_column_names block. If sort_column_names is an empty list, then the … |
|
- Change Summary:
-
- Added unit tests for the
columns=Noneandsort=Nonecases. - Fixed some incorrect and deprecated typing.
- Added unit tests for the
- Commits:
-
Summary ID a077d3ae3d5ccae704ea497cbb461dca45cb540e f6c5d3dbd37ba9d90a1a539942671dba6ae6829f - Diff:
-
Revision 2 (+840 -206)
Checks run (2 succeeded)
- Change Summary:
-
Moved some code out of an unnecessary conditional.
- Commits:
-
Summary ID f6c5d3dbd37ba9d90a1a539942671dba6ae6829f b60b8f39ff477c8b6cc122ce62163fdf63aa25c1 - Diff:
-
Revision 3 (+854 -224)