Skip to content

Commit 57c7b90

Browse files
authored
Merge pull request #437 from BSd3v/v34
updates for the changes to v35
2 parents a7ca1b8 + 7902dde commit 57c7b90

File tree

7 files changed

+110
-5
lines changed

7 files changed

+110
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ 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

77
## [unreleased]
8+
9+
### Added
10+
- [#436](https://github.com/plotly/dash-ag-grid/pull/436) Enabled Filter Handlers to simplify custom filter components by splitting the filter logic out from the UI component.
11+
12+
## [34.0.0rc0] - 2026-01-21
813
### Fixed
914
- [#408](https://github.com/plotly/dash-ag-grid/pull/408) fixed issue where the `columnState` would conflict with `columnDefs` updates
1015
- fixes [#416] (https://github.com/plotly/dash-ag-grid/issues/416)

src/lib/fragments/AgGrid.react.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,9 @@ export function DashAgGrid(props) {
564564
if (has('function', value)) {
565565
return convertMaybeFunctionNoParams(value);
566566
}
567-
return convertCol(value);
567+
if (typeof value === 'object') {
568+
return convertCol(value);
569+
}
568570
}
569571
// not one of those categories - pass it straight through
570572
return value;

src/lib/utils/propCategories.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,17 @@ export const GRID_NESTED_FUNCTIONS = {
185185
**/
186186
export const COLUMN_MAYBE_FUNCTIONS_NO_PARAMS = {
187187
cellEditor: 1,
188-
filter: 1,
189188

190189
// Columns: Sort
191190
comparator: 1,
192191
pivotComparator: 1,
193192

194193
// filter params custom option
195194
predicate: 1,
195+
196+
// filter
197+
doesFilterPass: 1,
198+
handler: 1,
196199
};
197200

198201
/**
@@ -299,6 +302,7 @@ export const COLUMN_NESTED_OR_OBJ_OF_FUNCTIONS = {
299302
**/
300303
export const COLUMN_NESTED_OR_OBJ_OF_FUNCTIONS_NO_PARAMS = {
301304
filterParams: 1,
305+
filter: 1,
302306
};
303307

304308
/**

tests/assets/dashAgGridComponentFunctions.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,31 @@ dagcomponentfuncs.myCustomButton2 = function (props) {
137137
className: props.value.className,
138138

139139
}, 'test cellRendererData'))
140-
}
140+
}
141+
142+
143+
dagcomponentfuncs.YearFilter34 = (props) => {
144+
const [year, setYear] = useState('All');
145+
146+
useEffect(() => {
147+
props.onModelChange(year === "All" ? null : year)
148+
}, [year]);
149+
150+
setProps = ({value}) => {
151+
if (value) {
152+
setYear(value)
153+
}
154+
}
155+
156+
return React.createElement(
157+
window.dash_core_components.RadioItems,
158+
{
159+
options: [
160+
{'label': 'All', 'value': 'All'},
161+
{'label': 'Since 2010', 'value': '2010'},
162+
],
163+
value: year,
164+
setProps
165+
}
166+
)
167+
};

tests/assets/dashAgGridFunctions.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ dagfuncs.YearFilter = forwardRef((props, ref) => {
221221
)
222222
});
223223

224+
225+
// for v34 filter logic seperate from component
226+
dagfuncs.doesFilterPass = (params) => {
227+
return params.data.year >= 2010;
228+
}
229+
224230
dagfuncs.setBody = () => {
225231
return document.querySelector('body')
226232
}

tests/test_custom_filter.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,67 @@ def test_fi003_custom_filter(dash_duo):
125125
grid.wait_for_cell_text(0, 0, "23")
126126

127127

128+
def test_fi003_custom_filter_v34(dash_duo):
129+
app = Dash(__name__)
130+
131+
df = pd.read_json('https://www.ag-grid.com/example-assets/olympic-winners.json', convert_dates=False)
132+
133+
rowData = df.to_dict('records')
134+
135+
columnDefs = [
136+
{'field': 'age', 'filter': 'agNumberColumnFilter'},
137+
{'field': 'country', 'minWidth': 150},
138+
{'field': 'year', 'filter': {'component': 'YearFilter34', 'doesFilterPass': {'function': 'doesFilterPass'}}},
139+
{
140+
'field': 'date',
141+
'minWidth': 130,
142+
'filter': 'agDateColumnFilter',
143+
},
144+
{'field': 'sport'},
145+
{'field': 'gold', 'filter': 'agNumberColumnFilter'},
146+
{'field': 'silver', 'filter': 'agNumberColumnFilter'},
147+
{'field': 'bronze', 'filter': 'agNumberColumnFilter'},
148+
{'field': 'total', 'filter': 'agNumberColumnFilter'},
149+
]
150+
151+
defaultColDef = {
152+
'editable': True,
153+
'sortable': True,
154+
'flex': 1,
155+
'minWidth': 100,
156+
'filter': True,
157+
'resizable': True,
158+
}
159+
160+
app.layout = html.Div(
161+
[
162+
dag.AgGrid(
163+
id="grid",
164+
columnDefs=columnDefs,
165+
rowData=rowData,
166+
defaultColDef=defaultColDef,
167+
dashGridOptions={"enableFilterHandlers": True}
168+
),
169+
]
170+
)
171+
172+
dash_duo.start_server(app)
173+
174+
grid = utils.Grid(dash_duo, "grid")
175+
176+
grid.wait_for_cell_text(0, 0, "23")
177+
178+
dash_duo.find_element('.ag-header-cell[aria-colindex="3"] span[data-ref="eFilterButton"]').click()
179+
180+
dash_duo.find_element('.ag-filter label:nth-child(2)').click()
181+
182+
grid.wait_for_cell_text(0, 0, "27")
183+
184+
dash_duo.find_element('.ag-filter label:nth-child(1)').click()
185+
186+
grid.wait_for_cell_text(0, 0, "23")
187+
188+
128189
# test filterParams.textFormatter, filterParams.textMatcher and filterParams.filterOptions.predicate functions
129190
def test_fi004_custom_filter(dash_duo):
130191
app = Dash(__name__)

tests/test_infinite_scroll.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ def infinite_scroll(request):
152152
grid.get_header_cell(0).click()
153153
grid.wait_for_cell_text(0, 0, "9999")
154154
grid.get_header_cell(1).click()
155-
grid.wait_for_cell_text(1, 0, "3600")
155+
grid.wait_for_cell_text(0, 1, "0-0-0")
156156
grid.get_header_cell(1).click()
157-
grid.wait_for_cell_text(0, 0, "7263")
157+
grid.wait_for_cell_text(0, 1, "4-6-7")
158158

159159

160160
def test_is002_infinite_scroll_styling(dash_duo):

0 commit comments

Comments
 (0)