Pass a handler to filter button property

2019-09-06 14:26发布

问题:

So I have a handler for when I right click it , it will clear the criteria. How do I set this in setFilterButtonProperties? I want to be able to right click the filter button, it should clear all the characters I typed into the filter fields.

        addFilterEditorSubmitHandler(new FilterEditorSubmitHandler()
        {

            @Override
            public void onFilterEditorSubmit(FilterEditorSubmitEvent event)
            {
                if (event.isRightButtonDown())
                {
                    SC.warn("right clicked");
                    clearCriteria();

                }
            }

        });

setFilterButtonProperties();

回答1:

Keep the functionality separate. There is no meaning of mixing two different tasks on the same button. Think from the end user's perspective.

Don't use right click of the button because that's not common practice. How come the end user know about the new functionality until and unless hover is visible? As per the icon that looks like to apply the filters, not meant for clearing the already applied filters.

In short, create a separate button that's sole purpose is to clear the applied filter. You can add the button in the header/footer as shown here in Smart GWT Showcase.

To clear the already applied filter simply call ListGrid#fetchData() again without passing any criteria means null on click of the new button.



标签: gwt smartgwt