Black Lives Matter. Please consider donating to Black Girls Code today.

DataTable filtering


I implemented a table with front-end filtering as described in the documentation:

My question is:
Is it possible to modify the filters? For example, so that “asia” returns the same result as “Asia”.


You should tweak the filtering function a little:

Instead of:

elif operator == 'contains':
            dff = dff.loc[dff[col_name].str.contains(filter_value)]

You should change it to:

elif operator == 'contains':
            dff = dff.loc[dff[col_name].str.contains(f'(?i){filter_value}')]

That will make the filter not case sensitive.

Thanks @marlon. So I guess this is only possible with back-end filtering?

Not sure. But that’s the path that I took since it’s more flexible and based on the documentation, it runs faster especially on large datasets.

Yes. I took the other route. I’ll probably switch now. Thanks again!