Skip to content

Commit 87233d5

Browse files
authored
Merge pull request #452 from BSd3v/fix-obj-maybefunction
fix #451
2 parents 87791f5 + 6e71bb9 commit 87233d5

3 files changed

Lines changed: 50 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ Links "DE#nnn" prior to version 2.0 point to the Dash Enterprise closed-source D
88
### Added
99
- [#453](https://github.com/plotly/dash-ag-grid/pull/453) Test for changelog entry
1010

11+
### Changed
12+
- [#452](https://github.com/plotly/dash-ag-grid/pull/452)
13+
- Added test for `OBJ_MAYBE_FUNCTION_OR_MAP_MAYBE_FUNCTIONS` to test that the value is an object before parsing,
14+
- this allows for reused keys to not comply with being an object
15+
1116

1217
## [35.2.0] - 2026-04-03
1318
### Added

src/lib/fragments/AgGrid.react.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -529,24 +529,26 @@ export function DashAgGrid(props) {
529529
});
530530
}
531531
if (OBJ_MAYBE_FUNCTION_OR_MAP_MAYBE_FUNCTIONS[target]) {
532-
if ('function' in value) {
533-
if (typeof value.function === 'string') {
534-
return convertMaybeFunctionNoParams(value);
535-
}
536-
}
537-
return map((v) => {
538-
if (
539-
typeof v === 'object' &&
540-
v !== null &&
541-
!Array.isArray(v)
542-
) {
543-
if (typeof v.function === 'string') {
544-
return convertMaybeFunctionNoParams(v);
532+
if (typeof value === 'object') {
533+
if ('function' in value) {
534+
if (typeof value.function === 'string') {
535+
return convertMaybeFunctionNoParams(value);
545536
}
546-
return convertCol(v);
547537
}
548-
return v;
549-
}, value);
538+
return map((v) => {
539+
if (
540+
typeof v === 'object' &&
541+
v !== null &&
542+
!Array.isArray(v)
543+
) {
544+
if (typeof v.function === 'string') {
545+
return convertMaybeFunctionNoParams(v);
546+
}
547+
return convertCol(v);
548+
}
549+
return v;
550+
}, value);
551+
}
550552
}
551553
if (
552554
COLUMN_NESTED_FUNCTIONS[target] &&

tests/test_cell_data_type_override.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import dash_ag_grid as dag
44
from dash import Dash, html
5+
import plotly.express as px
56
from . import utils
67

78
def test_cd001_cell_data_types_override(enforced_locale, dash_duo):
@@ -146,4 +147,29 @@ def test_cd002_column_types_formatting(dash_duo):
146147
input_el = dash_duo.find_element("#grid-column-types .ag-input-field-input")
147148
input_el.send_keys("0.2" + Keys.ENTER)
148149

149-
grid.wait_for_cell_text(0, 1, "0.200")
150+
grid.wait_for_cell_text(0, 1, "0.200")
151+
152+
def test_cd003_column_types_overriding(dash_duo):
153+
df = px.data.iris()
154+
155+
app = Dash(__name__)
156+
157+
app.layout = html.Div(
158+
[
159+
dag.AgGrid(
160+
rowData=df.to_dict("records"),
161+
columnDefs=[{"field": c} for c in df.columns],
162+
dashGridOptions={
163+
"dataTypeDefinitions": {
164+
"number": {
165+
"columnTypes": "rightAligned",
166+
}
167+
}
168+
},
169+
id='grid'
170+
)
171+
]
172+
)
173+
174+
dash_duo.start_server(app)
175+
grid = utils.Grid(dash_duo, "grid")

0 commit comments

Comments
 (0)