Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ 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
- [#328](https://github.com/plotly/dash-ag-grid/pull/328) fixed issue where `getRowStyle` wast able to be passed as a complete function

### Changed
- [#328](https://github.com/plotly/dash-ag-grid/pull/328)
- bumping to v`32.3` for the grid
- the grid checks if updates are from an internal source (3.0.2 dash) and will selectively rerender if so

## [31.3.1] - 2025-03-17

### Fixed
Expand Down
112 changes: 74 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-ag-grid",
"version": "31.3.1",
"version": "32.3.0",
"description": "Dash wrapper around AG Grid, the best interactive data grid for the web.",
"repository": {
"type": "git",
Expand All @@ -25,17 +25,16 @@
"private::lint.eslint": "eslint src",
"private::lint.prettier": "prettier src --list-different --ignore-path=.prettierignore",
"lint": "run-s private::lint.*",
"test": "pytest --headless",
"dist": "npm run build && run-s pre-flight-dag-version && rimraf build dist && python setup.py sdist bdist_wheel"
"dist": "npm run build && run-s pre-flight-dag-version && python setup.py sdist bdist_wheel"
},
"author": "Plotly <chris@plot.ly>",
"license": "MIT",
"dependencies": {
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"ag-grid-community": "31.3.4",
"ag-grid-enterprise": "31.3.4",
"ag-grid-react": "31.3.4",
"ag-grid-community": "32.3.4",
"ag-grid-enterprise": "32.3.4",
"ag-grid-react": "32.3.4",
Comment on lines -36 to +37
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is retaining the minor and patch versions deliberate? do we want to just update to the latest minor/patch versions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we didnt want things to randomly get out of sync.

"@mui/icons-material": "^5.15.7",
"@mui/material": "^5.15.7",
"d3-format": "^3.1.0",
Expand Down
11 changes: 10 additions & 1 deletion src/lib/components/AgGrid.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function getGrid(enable) {
/**
* Dash interface to AG Grid, a powerful tabular data component.
*/
export default class DashAgGrid extends Component {
class DashAgGrid extends Component {
constructor(props) {
super(props);

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

static dashRenderType = true;

buildArray(arr1, arr2) {
if (arr1) {
if (!arr1.includes(arr2)) {
Expand Down Expand Up @@ -750,11 +752,18 @@ DashAgGrid.propTypes = {
* Other ag-grid options
*/
dashGridOptions: PropTypes.object,

/**
* dashRenderType to determine why grid is rendering
*/
dashRenderType: PropTypes.string,
};

export const propTypes = DashAgGrid.propTypes;
export const defaultProps = DashAgGrid.defaultProps;

export default DashAgGrid;

export const apiGetters = {};

const _get = (flavor) => (id) => {
Expand Down
33 changes: 22 additions & 11 deletions src/lib/fragments/AgGrid.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import MarkdownRenderer from '../renderers/markdownRenderer';
import RowMenuRenderer from '../renderers/rowMenuRenderer';
import {customFunctions} from '../renderers/customFunctions';

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

import 'ag-grid-community/styles/ag-grid.css';
import 'ag-grid-community/styles/ag-theme-alpine.css';
Expand Down Expand Up @@ -488,7 +488,10 @@ export default class DashAgGrid extends Component {
if (target === 'getRowId') {
return this.convertFunction(value);
}
if (target === 'getRowStyle') {
if (
target === 'getRowStyle' &&
(has('styleConditions', value) || has('defaultStyle', value))
) {
return this.handleDynamicStyle(value);
}
if (OBJ_OF_FUNCTIONS[target]) {
Expand Down Expand Up @@ -604,7 +607,10 @@ export default class DashAgGrid extends Component {
!equals(
{...omit(OMIT_PROP_RENDER, nextProps)},
{...omit(OMIT_PROP_RENDER, this.props)}
)
) &&
(nextProps?.dashRenderType !== 'internal' ||
!equals(nextProps.rowData, this.props.rowData) ||
!equals(nextProps.selectedRows, this.props.selectedRows))
) {
return true;
}
Expand All @@ -617,14 +623,16 @@ export default class DashAgGrid extends Component {
return true;
}
if (gridApi && !gridApi?.isDestroyed()) {
if (columnState) {
if (columnState !== this.props.columnState) {
return true;
if (nextProps?.dashRenderType !== 'internal') {
if (columnState) {
if (columnState !== this.props.columnState) {
return true;
}
}
}
if (filterModel) {
if (!equals(filterModel, gridApi.getFilterModel())) {
return true;
if (filterModel) {
if (!equals(filterModel, gridApi.getFilterModel())) {
return true;
}
}
}
if (selectedRows) {
Expand Down Expand Up @@ -1170,7 +1178,7 @@ export default class DashAgGrid extends Component {
cellRendererData: {
value,
colId: props.column.colId,
rowIndex: props.rowIndex,
rowIndex: props.node.sourceRowIndex,
rowId: props.node.id,
timestamp: Date.now(),
},
Expand Down Expand Up @@ -1494,3 +1502,6 @@ DashAgGrid.propTypes = {parentState: PropTypes.any, ..._propTypes};

export const propTypes = DashAgGrid.propTypes;
export const defaultProps = DashAgGrid.defaultProps;

var dagfuncs = (window.dash_ag_grid = window.dash_ag_grid || {});
dagfuncs.useGridFilter = useGridFilter;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's dagfuncs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A way to pass the internal api things to the app developer. For example, this passes useGridFilter to be used in the difference of useImperativeHandler between 31 and 32. This way they can use filters like they were the component developer.

38 changes: 18 additions & 20 deletions tests/assets/dashAgGridFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,29 +184,23 @@ const {useImperativeHandle, useState, useEffect, forwardRef} = React;
dagfuncs.YearFilter = forwardRef((props, ref) => {
const [year, setYear] = useState('All');

useImperativeHandle(ref, () => {
return {
doesFilterPass(params) {
return params.data.year >= 2010;
},
dash_ag_grid.useGridFilter({
doesFilterPass(params) {
return params.data.year >= 2010;
},

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

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

setModel() {
}
}
});

useEffect(() => {
props.filterChangedCallback()
}, [year]);
useEffect(() => {
props.onModelChange(year === "All" ? null : year)
}, [year]);

setProps = ({value}) => {
if (value) {
Expand Down Expand Up @@ -504,4 +498,8 @@ dagfuncs.sortColumns = (a, b) => b.localeCompare(a)
dagfuncs.TestEvent = (params, setEventData) => {
console.log(params)
setEventData('here I am')
}

dagfuncs.testToyota = (params) => {
return params.data.make == 'Toyota' ? {'color': 'blue'} : {}
}
Loading