0

我想在文本字段中过滤没有类型的树,但是在触发事件时。我尝试像这样子类化 StoreFilterField:

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;
        }

    };

当我想过滤我的树时:

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

但不起作用,我的过滤器显示了我树的所有项目。怎么了?

4

1 回答 1

0

我解决了自己添加这个构造函数的问题:

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);
      }
    };
}
于 2013-02-22T16:14:52.907 回答