Skip to content

Commit 0f3b00a

Browse files
authored
Merge pull request #328 from BSd3v/bump-to-v32_2
bump to AG Grid version `32.3`
2 parents eed8460 + 836c274 commit 0f3b00a

File tree

8 files changed

+204
-77
lines changed

8 files changed

+204
-77
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ 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+
- [#328](https://github.com/plotly/dash-ag-grid/pull/328) fixed issue where `getRowStyle` wast able to be passed as a complete function
11+
12+
### Changed
13+
- [#328](https://github.com/plotly/dash-ag-grid/pull/328)
14+
- bumping to v`32.3` for the grid
15+
- the grid checks if updates are from an internal source (3.0.2 dash) and will selectively rerender if so
16+
717
## [31.3.1] - 2025-03-17
818

919
### Fixed

package-lock.json

Lines changed: 74 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dash-ag-grid",
3-
"version": "31.3.1",
3+
"version": "32.3.0",
44
"description": "Dash wrapper around AG Grid, the best interactive data grid for the web.",
55
"repository": {
66
"type": "git",
@@ -25,17 +25,16 @@
2525
"private::lint.eslint": "eslint src",
2626
"private::lint.prettier": "prettier src --list-different --ignore-path=.prettierignore",
2727
"lint": "run-s private::lint.*",
28-
"test": "pytest --headless",
29-
"dist": "npm run build && run-s pre-flight-dag-version && rimraf build dist && python setup.py sdist bdist_wheel"
28+
"dist": "npm run build && run-s pre-flight-dag-version && python setup.py sdist bdist_wheel"
3029
},
3130
"author": "Plotly <[email protected]>",
3231
"license": "MIT",
3332
"dependencies": {
3433
"@emotion/react": "^11.11.3",
3534
"@emotion/styled": "^11.11.0",
36-
"ag-grid-community": "31.3.4",
37-
"ag-grid-enterprise": "31.3.4",
38-
"ag-grid-react": "31.3.4",
35+
"ag-grid-community": "32.3.4",
36+
"ag-grid-enterprise": "32.3.4",
37+
"ag-grid-react": "32.3.4",
3938
"@mui/icons-material": "^5.15.7",
4039
"@mui/material": "^5.15.7",
4140
"d3-format": "^3.1.0",

src/lib/components/AgGrid.react.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function getGrid(enable) {
1212
/**
1313
* Dash interface to AG Grid, a powerful tabular data component.
1414
*/
15-
export default class DashAgGrid extends Component {
15+
class DashAgGrid extends Component {
1616
constructor(props) {
1717
super(props);
1818

@@ -24,6 +24,8 @@ export default class DashAgGrid extends Component {
2424
this.buildArray = this.buildArray.bind(this);
2525
}
2626

27+
static dashRenderType = true;
28+
2729
buildArray(arr1, arr2) {
2830
if (arr1) {
2931
if (!arr1.includes(arr2)) {
@@ -750,11 +752,18 @@ DashAgGrid.propTypes = {
750752
* Other ag-grid options
751753
*/
752754
dashGridOptions: PropTypes.object,
755+
756+
/**
757+
* dashRenderType to determine why grid is rendering
758+
*/
759+
dashRenderType: PropTypes.string,
753760
};
754761

755762
export const propTypes = DashAgGrid.propTypes;
756763
export const defaultProps = DashAgGrid.defaultProps;
757764

765+
export default DashAgGrid;
766+
758767
export const apiGetters = {};
759768

760769
const _get = (flavor) => (id) => {

src/lib/fragments/AgGrid.react.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import MarkdownRenderer from '../renderers/markdownRenderer';
4646
import RowMenuRenderer from '../renderers/rowMenuRenderer';
4747
import {customFunctions} from '../renderers/customFunctions';
4848

49-
import {AgGridReact} from 'ag-grid-react';
49+
import {AgGridReact, useGridFilter} from 'ag-grid-react';
5050

5151
import 'ag-grid-community/styles/ag-grid.css';
5252
import 'ag-grid-community/styles/ag-theme-alpine.css';
@@ -488,7 +488,10 @@ export default class DashAgGrid extends Component {
488488
if (target === 'getRowId') {
489489
return this.convertFunction(value);
490490
}
491-
if (target === 'getRowStyle') {
491+
if (
492+
target === 'getRowStyle' &&
493+
(has('styleConditions', value) || has('defaultStyle', value))
494+
) {
492495
return this.handleDynamicStyle(value);
493496
}
494497
if (OBJ_OF_FUNCTIONS[target]) {
@@ -604,7 +607,10 @@ export default class DashAgGrid extends Component {
604607
!equals(
605608
{...omit(OMIT_PROP_RENDER, nextProps)},
606609
{...omit(OMIT_PROP_RENDER, this.props)}
607-
)
610+
) &&
611+
(nextProps?.dashRenderType !== 'internal' ||
612+
!equals(nextProps.rowData, this.props.rowData) ||
613+
!equals(nextProps.selectedRows, this.props.selectedRows))
608614
) {
609615
return true;
610616
}
@@ -617,14 +623,16 @@ export default class DashAgGrid extends Component {
617623
return true;
618624
}
619625
if (gridApi && !gridApi?.isDestroyed()) {
620-
if (columnState) {
621-
if (columnState !== this.props.columnState) {
622-
return true;
626+
if (nextProps?.dashRenderType !== 'internal') {
627+
if (columnState) {
628+
if (columnState !== this.props.columnState) {
629+
return true;
630+
}
623631
}
624-
}
625-
if (filterModel) {
626-
if (!equals(filterModel, gridApi.getFilterModel())) {
627-
return true;
632+
if (filterModel) {
633+
if (!equals(filterModel, gridApi.getFilterModel())) {
634+
return true;
635+
}
628636
}
629637
}
630638
if (selectedRows) {
@@ -1170,7 +1178,7 @@ export default class DashAgGrid extends Component {
11701178
cellRendererData: {
11711179
value,
11721180
colId: props.column.colId,
1173-
rowIndex: props.rowIndex,
1181+
rowIndex: props.node.sourceRowIndex,
11741182
rowId: props.node.id,
11751183
timestamp: Date.now(),
11761184
},
@@ -1494,3 +1502,6 @@ DashAgGrid.propTypes = {parentState: PropTypes.any, ..._propTypes};
14941502

14951503
export const propTypes = DashAgGrid.propTypes;
14961504
export const defaultProps = DashAgGrid.defaultProps;
1505+
1506+
var dagfuncs = (window.dash_ag_grid = window.dash_ag_grid || {});
1507+
dagfuncs.useGridFilter = useGridFilter;

tests/assets/dashAgGridFunctions.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -184,29 +184,23 @@ const {useImperativeHandle, useState, useEffect, forwardRef} = React;
184184
dagfuncs.YearFilter = forwardRef((props, ref) => {
185185
const [year, setYear] = useState('All');
186186

187-
useImperativeHandle(ref, () => {
188-
return {
189-
doesFilterPass(params) {
190-
return params.data.year >= 2010;
191-
},
187+
dash_ag_grid.useGridFilter({
188+
doesFilterPass(params) {
189+
return params.data.year >= 2010;
190+
},
192191

193-
isFilterActive() {
194-
return year === '2010'
195-
},
192+
// this example isn't using getModel() and setModel(),
193+
// so safe to just leave these empty. don't do this in your code!!!
194+
getModel() {
195+
},
196196

197-
// this example isn't using getModel() and setModel(),
198-
// so safe to just leave these empty. don't do this in your code!!!
199-
getModel() {
200-
},
197+
setModel() {
198+
}
199+
});
201200

202-
setModel() {
203-
}
204-
}
205-
});
206-
207-
useEffect(() => {
208-
props.filterChangedCallback()
209-
}, [year]);
201+
useEffect(() => {
202+
props.onModelChange(year === "All" ? null : year)
203+
}, [year]);
210204

211205
setProps = ({value}) => {
212206
if (value) {
@@ -504,4 +498,8 @@ dagfuncs.sortColumns = (a, b) => b.localeCompare(a)
504498
dagfuncs.TestEvent = (params, setEventData) => {
505499
console.log(params)
506500
setEventData('here I am')
501+
}
502+
503+
dagfuncs.testToyota = (params) => {
504+
return params.data.make == 'Toyota' ? {'color': 'blue'} : {}
507505
}

0 commit comments

Comments
 (0)