GWT StoreFilterField - auto filter

江枫思渺然 提交于 2020-01-17 05:19:01

问题


I would like to filter a tree without type in the textfield, but when an event is triggered. I tried subclassing StoreFilterField like this:

class MyStoreFilter<M extends ModelData> extends StoreFilterField<M>{
public MyStoreFilter() {
            super();
        }

        public void startFilter(){
            super.onFilter();
        }


        @Override
        protected boolean doSelect(Store<M> store, M parent, M record,
                String property, String filter) {
            String name = record.get("name");
            name = name.toLowerCase();
            if (name.startsWith(filter.toLowerCase())) 
                return true;
            else
                return false;
        }

    };

And when i want to filter my tree:

MyStoreFilter<ModelData> f=new MyStoreFilter<ModelData>();
f.setRawValue(myText);
f.bind(store);
f.startFilter();

But doesn't work, and my filter shows all items of my tree. What is wrong?


回答1:


I solved myself adding this constructor:

public MyStoreFilter(String f)  {
    filtro=f;
    setAutoValidate(true);
    setValidateOnBlur(false);
    setTriggerStyle("x-form-clear-trigger");
    filter = new StoreFilter<M>() {
      public boolean select(Store<M> store, M parent, M model, String property) {
        String v = filtro;
        return doSelect(store, parent, model, property, v);
      }
    };
}


来源:https://stackoverflow.com/questions/15006376/gwt-storefilterfield-auto-filter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!