Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control column filters from script (upon initialisation) #390

Open
sachin-smart opened this issue Jan 11, 2023 · 1 comment
Open

Control column filters from script (upon initialisation) #390

sachin-smart opened this issue Jan 11, 2023 · 1 comment

Comments

@sachin-smart
Copy link

sachin-smart commented Jan 11, 2023

Is your feature request related to a problem? Please describe.
Yes, I am currently unable to initialise a data grid with a set of filters on specific columns or control those filters from other widgets or elsewhere in a script.

Describe the solution you'd like
I would like to be able to filter the data grid from the script itself, including upon initialisation. An example is that I would like to filter a column to hide all rows where the value in that column in 0. Importantly, I do not want to filter that data frame in pandas before initialisation for 2 reasons: (1) the user should be able to remove this filter from the point-and-click menu at the top of the columns; and (2) certain calculations are done using the full set of data, and so the rows just need to be hidden, not removed entirely. The effective outcome would be identical to if I opened the data grid and then manually clicked on the filter for that column and removed 0 from the list of values. This is currently what I do.

Describe alternatives you've considered
I looked in the get_state() method and found the _transforms attribute. This seems to have the relevant information for the filter, but as a private attribute, I expect it is not advisable to control this from the script directly.

[{'type': 'filter', 'columnIndex': 8, 'operator': 'in', 'value': ...

@bergmanngabor
Copy link

Have you tried datagrid.transform( [{'type': 'filter', 'columnIndex': 8, 'operator': 'in', 'value': ...}] ) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants