I have a dash-ag-grid table that uses the infinite
row model. I have the filter set up just like in the dash docs but i also want to have a quick filter, and that has to be implemented server-side. Does anybody have code for this?
Hello @aboyher,
Here is an example of how you can accomplish this:
import json
data = [
{'name': 'xY7b3A9Z', 'age': 'p2R8s1T6', 'city': 'o4N0m5P7'},
{'name': 'c1D9e2F4G', 'age': 'h5J3k7L0', 'city': 'q6S8t4U2'},
{'name': 'v3W1x5Y7Z', 'age': 'r9B2d6C8', 'city': 'i0F4g7H9'},
{'name': 'n6M8o2P4Q', 'age': 'j5K7l1I3', 'city': 'w9X3y7Z1'},
{'name': 's4T6u8V0W', 'age': 'e2G4h6J8', 'city': 'm1O3p5Q7'}
]
def compare_records(array_of_dicts, column_values):
matched_dicts = []
for dictionary in array_of_dicts:
dict_values_str = ' '.join(map(str, dictionary.values()))
test = True
for x in column_values:
if x.lower() not in dict_values_str.lower():
test = False
break
if test:
matched_dicts.append(dictionary)
return matched_dicts
print(compare_records(data, ['s', '7']))
1 Like