From 5ea15e6fd92323cea254049af23d109e391d2536 Mon Sep 17 00:00:00 2001 From: BSd3v Date: Mon, 2 Dec 2024 15:16:04 -0500 Subject: [PATCH 1/4] adjusting styling to check if the `node` exists, instead of testing for `data`, this fixes an issue with `rowGrouping` not passing through the styling conditions --- src/lib/fragments/AgGrid.react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/fragments/AgGrid.react.js b/src/lib/fragments/AgGrid.react.js index 74454cc8..3ef8b4a8 100644 --- a/src/lib/fragments/AgGrid.react.js +++ b/src/lib/fragments/AgGrid.react.js @@ -1125,7 +1125,7 @@ export default class DashAgGrid extends Component { return (params) => { for (const {test, style} of tests) { if (params) { - if (params.data) { + if (params.node) { if (test(params)) { return style; } From 7195d46aaa6eb8b904c5429128f8529be7689b2d Mon Sep 17 00:00:00 2001 From: BSd3v Date: Mon, 2 Dec 2024 16:49:25 -0500 Subject: [PATCH 2/4] fixing `node` test to check for an `id` of the `node` as `data` didnt always exist in the `infinite` model even if the `node` was present --- src/lib/fragments/AgGrid.react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/fragments/AgGrid.react.js b/src/lib/fragments/AgGrid.react.js index 3ef8b4a8..fa4d8138 100644 --- a/src/lib/fragments/AgGrid.react.js +++ b/src/lib/fragments/AgGrid.react.js @@ -1125,7 +1125,7 @@ export default class DashAgGrid extends Component { return (params) => { for (const {test, style} of tests) { if (params) { - if (params.node) { + if (params.node.id && params.node.id !== null) { if (test(params)) { return style; } From 142ca3eb709c9f992729186c8b016d0393cc50bb Mon Sep 17 00:00:00 2001 From: BSd3v Date: Mon, 2 Dec 2024 17:05:47 -0500 Subject: [PATCH 3/4] Adding test for Enterprise row grouping with styling --- tests/test_conditional_formatting.py | 80 ++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/tests/test_conditional_formatting.py b/tests/test_conditional_formatting.py index 6fb8586a..c4d16f39 100644 --- a/tests/test_conditional_formatting.py +++ b/tests/test_conditional_formatting.py @@ -2,6 +2,7 @@ from dash import Dash, html, dcc from . import utils from dash.testing.wait import until +import pandas as pd def test_cf001_conditional_formatting(dash_duo): @@ -98,3 +99,82 @@ def test_cf001_conditional_formatting(dash_duo): lambda: "color: orange" in grid.get_cell(0, 2).get_attribute("style"), timeout=3 ) assert "color: orange" in grid.get_cell(0, 0).get_attribute("style") + +def test_cf002_conditional_formatting_enterprise(dash_duo): + app = Dash(__name__) + + df = pd.read_csv( + "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv" + ) + + columnDefs = [ + # Row group by country and by year is enabled. + { + "field": "country", + "rowGroup": True, + "hide": True, + "suppressColumnsToolPanel": True, + }, + { + "field": "gold", + "filter": True, + "aggFunc": "sum", + "valueFormatter": {"function": "d3.format('(,.2f')(params.value)"}, + "cellStyle": { + + "styleConditions": [ + + { + "condition": f"params.value < 100", + "style": {"backgroundColor": "lightgreen"}, + }, + + ], + "defaultStyle": {"backgroundColor": "yellow"}, + }, + + }, + ] + + app.layout = html.Div( + [ + dag.AgGrid( + id="grid", + columnDefs=columnDefs, + rowData=df.to_dict("records"), + defaultColDef=dict( + suppressAggFuncInHeader=True + ), + dashGridOptions={"rowSelection":"multiple", "animateRows": False}, + enableEnterpriseModules=True, + getRowStyle={ + "styleConditions": [ + { + "condition": "params.node.aggData ? params.node.aggData.gold < 3 : false", + "style": {"backgroundColor": "silver"}, + } + ] + }, + ), + ] + ) + + dash_duo.start_server(app) + + grid = utils.Grid(dash_duo, "grid") + + until( + lambda: "United States" in grid.get_cell(0, 0).text, timeout=3 + ) + + ### testing styles + until( + lambda: "background-color: yellow" in grid.get_cell(0, 2).get_attribute("style"), timeout=3 + ) + until( + lambda: "background-color: lightgreen" in grid.get_cell(4, 2).get_attribute("style"), timeout=3 + ) + until( + lambda: "background-color: silver" in grid.get_row(6).get_attribute("style"), + timeout=3, + ) \ No newline at end of file From 1b5f89832004a3d892111cc072cd22260505f360 Mon Sep 17 00:00:00 2001 From: BryanSchroeder Date: Mon, 16 Dec 2024 12:48:10 -0500 Subject: [PATCH 4/4] updating changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a48fa57..bbcced94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to `dash-ag-grid` will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/). Links "DE#nnn" prior to version 2.0 point to the Dash Enterprise closed-source Dash AG Grid repo +## [Unreleased] + +### Fixed + - [#346](https://github.com/plotly/dash-ag-grid/pull/346) Fixes issue [#347](https://github.com/plotly/dash-ag-grid/issues/347) where styling wasnt considering if the grid had rows without `data`. This is related to the alteration in [#332](https://github.com/plotly/dash-ag-grid/pull/332) + + ## [31.3.0] - 2024-11-22 ### Fixed