fix(data_table): give string columns their name as id
All Submissions:
- Have you followed the guidelines stated in CONTRIBUTING.md file?
- Have you checked to ensure there aren't any other open Pull Requests for the desired changed?
Type of change
- Bug fix (non-breaking change which fixes an issue)
Description
Fixes #6108. With dict rows, rx.data_table leaves a column blank when its name isn't already lowercase:
rx.data_table(data=[{"Route": "1", "To": "Central", "from": "Tsuen Wan"}], columns=["Route", "To", "from"])
Only "from" shows values. Grid.js makes the id route for a string column "Route" and reads dict rows by that id.
String columns now become {"id": col, "name": col}, built with Var operations as masenf suggested in #6111, so it also works when the columns come from state. This is done once in create(). Column objects you pass yourself are left alone, and rows given as lists (and dataframes) are read by position, so they look the same as before.
One thing changes: dict rows keyed by the lowercased name, like columns=["Name"] with {"name": ...}, only matched because of Grid.js's id. They now need the key to match the column. The news file says so.
| Before | After |
|---|---|
Without the fix, 5 of the tests fail. Unit suite and pre-commit pass.