Skip to content

Commit 8a9f296

Browse files
authored
Merge pull request #396 from plotly/backport/394-cellRenderer-fn
Backport: allow cellRenderer to be a fn in a colDef
2 parents afeaeb9 + a5b301a commit 8a9f296

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

.github/workflows/python-test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ on:
99
tags:
1010
- v*
1111
pull_request:
12-
branches: [main]
12+
branches:
13+
- main
14+
- v*
1315

1416
jobs:
1517
test:
@@ -104,4 +106,3 @@ jobs:
104106
run: |
105107
source .venv/bin/activate
106108
pytest --headless
107-

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+
## [32.3.1] - 2025-08-05
8+
9+
### Fixed
10+
- [#394](https://github.com/plotly/dash-ag-grid/issues/394) allow `cellRenderer` column def to be a function
11+
712
## [32.3.0] - 2025-07-23
813

914
### Changed

src/lib/utils/propCategories.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ export const COLUMN_MAYBE_FUNCTIONS = {
230230
cellStyle: 1,
231231
cellClass: 1,
232232
tooltipComponent: 1,
233+
cellRenderer: 1,
233234
cellRendererSelector: 1,
234235

235236
// 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)