Skip to content

filter_changed is not recognised in .on() #384

Open
@HariniMadhi

Description

@HariniMadhi

qgrid_widget.on doesn't recognixe 'filter_changed', 'filter_dropdown_shown'.

To replicate,

import qgrid
import pandas as pd
def func(change, a):
    print(change, a)

df = pd.DataFrame({'Highlight': ['1', '1', '0', '0', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '0'], 'Letters' :['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']})
qgrid_widget = qgrid.show_grid(df)
qgrid_widget.on('filter_changed', func)
qgrid_widget

The need for this:
To use the filter functionality within the program (not just as a User Interface feature).
I have used the below code to defaultly show the rows that have Highlight = 1.

qgrid_widget._handle_qgrid_msg_helper({'type':'show_filter_dropdown', 'field':'Highlight', 'search_val':'1'})
qgrid_widget._handle_qgrid_msg_helper({'field':'Highlight', 'filter_info':{'field':'Highlight', 'selected':[0], 'type':'text', 'excluded':[]}, 'type':'change_filter'})

But this reduces the size of the table, and when I use the filter to include the 0 as well, the dataframe populates only to the reduced height, and no scroll bar is available.
So I want to capture when the user is again clicking the filter in func(), and then call this

qgrid_widget._handle_qgrid_msg_helper({'field':'Highlight', 'filter_info':{'field':'Highlight','selected':[], 'type':'text', 'excluded':[]}, 'type':'change_filter'})

or

call qgrid.show_grid(df) in func.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions