@@ -236,3 +236,101 @@ def test_fi005_custom_filter(dash_duo):
236236 # Test numberParser and numberFormatter
237237 grid .set_filter (0 , "$100,5" )
238238 grid .wait_for_cell_text (0 , 0 , "$200,00" )
239+
240+ def test_fi006_custom_filter (dash_duo ):
241+ app = Dash (__name__ )
242+
243+ df = pd .read_csv (
244+ "https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv"
245+ )
246+
247+ columnDefs = [
248+ {"field" : "athlete" ,
249+ "filter" : "agMultiColumnFilter" ,
250+ "filterParams" : {
251+ "filters" : [
252+ {"filter" : "agTextColumnFilter" },
253+ {"filter" : "agSetColumnFilter" } # Example with Set Filter
254+ ]
255+ }},
256+ {"field" : "country" },
257+ {
258+ "field" : "date" ,
259+ "filter" : "agMultiColumnFilter" ,
260+ "filterParams" : {
261+ "filters" : [
262+ {
263+ "filter" : "agSetColumnFilter" ,
264+ 'filterParams' : {'excelMode' : 'windows' , 'buttons' : ['apply' , 'reset' ],
265+ }
266+ },
267+ {
268+ "filter" : "agDateColumnFilter" ,
269+ 'filterParams' : {
270+ 'excelMode' : 'windows' ,
271+ 'buttons' : ['apply' , 'reset' ],
272+ 'comparator' : {'function' : 'dateFilterComparator' },
273+ }
274+ },
275+ ],
276+
277+ },
278+ },
279+ ]
280+
281+
282+ app .layout = html .Div (
283+ [
284+ dag .AgGrid (
285+ id = "date-filter-example" ,
286+ enableEnterpriseModules = True ,
287+ columnDefs = columnDefs ,
288+ rowData = df .to_dict ("records" ),
289+ defaultColDef = {"flex" : 1 , "minWidth" : 150 , "floatingFilter" : True },
290+ dashGridOptions = {"animateRows" : False }
291+ ),
292+ ],
293+ )
294+
295+ dash_duo .start_server (app )
296+
297+ grid = utils .Grid (dash_duo , "date-filter-example" )
298+
299+ grid .wait_for_cell_text (0 , 0 , "Michael Phelps" )
300+
301+ # Test Set Filter - click filter button on date column
302+ dash_duo .find_element ('.ag-floating-filter[aria-colindex="3"] button' ).click ()
303+
304+ # Uncheck "Select All"
305+ dash_duo .find_element ('.ag-set-filter-list .ag-set-filter-item .ag-checkbox-input' ).click ()
306+
307+ # Select "24/08/2008"
308+ dash_duo .wait_for_element ('.ag-set-filter-list .ag-virtual-list-item' , timeout = 10 )
309+ set_filter_items = dash_duo .find_elements ('.ag-set-filter-list .ag-virtual-list-item' )
310+ checkboxes = dash_duo .find_elements ('.ag-set-filter-list .ag-virtual-list-item .ag-checkbox-input' )
311+
312+ for i , item in enumerate (set_filter_items ):
313+ if "24/08/2008" in item .text :
314+ checkboxes [i ].click ()
315+ break
316+
317+ # Apply
318+ dash_duo .find_element ('button[data-ref="applyFilterButton"]' ).click ()
319+ grid .wait_for_cell_text (0 , 2 , "24/08/2008" )
320+
321+ # Reset
322+ dash_duo .find_element ('.ag-floating-filter[aria-colindex="3"] button' ).click ()
323+ dash_duo .find_element ('button[data-ref="resetFilterButton"]' ).click ()
324+
325+ # Test Date Filter - click filter button again
326+ dash_duo .find_element ('.ag-floating-filter[aria-colindex="3"] button' ).click ()
327+
328+ # Type date
329+ date_input = dash_duo .find_element ('.ag-filter-wrapper .ag-date-filter input[class="ag-input-field-input ag-text-field-input"]' )
330+ date_input .click ()
331+ date_input .send_keys ("24-08-2008" )
332+
333+ # Apply
334+ apply_buttons = dash_duo .find_elements ('button[data-ref="applyFilterButton"]' )
335+ apply_buttons [1 ].click ()
336+ grid .wait_for_cell_text (0 , 2 , "24/08/2008" )
0 commit comments