Skip to content

Commit 6f84e90

Browse files
authored
Merge pull request #395 from plotly/bugfix/394-cellRenderer-fn
Bugfix: allow cellRenderer to be a fn in a colDef
2 parents 38857b6 + 5a4c98f commit 6f84e90

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to `dash-ag-grid` will be documented in this file.
44
This project adheres to [Semantic Versioning](https://semver.org/).
55
Links "DE#nnn" prior to version 2.0 point to the Dash Enterprise closed-source Dash AG Grid repo
66

7+
## UNRELEASED
8+
9+
### Fixed
10+
- [#394](https://github.com/plotly/dash-ag-grid/issues/394) allow `cellRenderer` column def to be a function
11+
712
## [33.3.2rc0] - 2025-07-29
813

914
### Changed

src/lib/utils/propCategories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ export const COLUMN_MAYBE_FUNCTIONS = {
233233
cellStyle: 1,
234234
cellClass: 1,
235235
tooltipComponent: 1,
236+
cellRenderer: 1,
236237
cellRendererSelector: 1,
237238

238239
// Columns: Row Dragging

tests/test_column_defs.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import dash_ag_grid as dag
2+
from dash import Dash, html, dcc
3+
from . import utils
4+
5+
6+
def test_cd001_cell_renderer_function(dash_duo):
7+
app = Dash(__name__)
8+
9+
rowData = [
10+
{"size": 0, "is_available": True},
11+
{"size": 1, "is_available": False},
12+
{"size": 2, "is_available": True},
13+
]
14+
15+
columnDefs = [
16+
{
17+
"field": "size",
18+
"cellRenderer": {"function": "params.value < 1 ? 'small' : params.value < 2 ? 'medium' : 'large'"},
19+
},
20+
{
21+
"field": "is_available",
22+
"cellRenderer": {"function": "params.value ? 'yes' : 'no'"},
23+
},
24+
]
25+
26+
app.layout = html.Div(
27+
[
28+
dcc.Markdown(
29+
"This grid uses a javascript function to display computed values for each cell, rather than the raw numbers."
30+
),
31+
dag.AgGrid(
32+
columnDefs=columnDefs,
33+
rowData=rowData,
34+
id="grid",
35+
),
36+
],
37+
style={"margin": 20},
38+
)
39+
40+
dash_duo.start_server(app)
41+
42+
grid = utils.Grid(dash_duo, "grid")
43+
44+
grid.wait_for_cell_text(0, 0, "small")
45+
grid.wait_for_cell_text(0, 1, "yes")
46+
grid.wait_for_cell_text(1, 0, "medium")
47+
grid.wait_for_cell_text(1, 1, "no")
48+
grid.wait_for_cell_text(2, 0, "large")
49+
grid.wait_for_cell_text(2, 1, "yes")

0 commit comments

Comments
 (0)