StringFilter 覆盖不起作用

StringFilter override not working

我正在尝试覆盖 Grid 使用的 StringFilter 的行为。 下面的代码没有一些功能,我只是想看看 validateModel 是否被调用。问题是,它从来没有被调用过。另一方面,onFieldKeyUp 被调用了。我究竟做错了什么?

我正在使用 Sencha GXT 3.1.0GWT 2.6.1Java 1.7

Filter<Record, ?> filter = new StringFilter<Record>(valueProvider)
{
    @Override
    protected void onFieldKeyUp(Event event) 
    {
        Window.alert("onFieldKeyUp");   //--> This is called
        int key = event.getKeyCode();
        if (key == KeyCodes.KEY_ENTER && field.isValid()) 
        {
            event.stopPropagation();
            event.preventDefault();
            menu.hide(true);

            return;
        }

        super.onFieldKeyUp(event);
    }

    @Override
    protected boolean validateModel(Record model) 
    {
        Window.alert("validateModel");   //--> This is NOT called
        String rowValue = getValueProvider().getValue(model);
        rowValue = (rowValue == null) ? "" : rowValue;
        Object filterObject = getValue();
        String filterValue = filterObject == null ? "" : String.valueOf(filterObject);

        if (filterValue.isEmpty() && rowValue.isEmpty()) 
        {
            return true;
        } 
        else 
        {
            //Here I want to put some more code manipulating the filtevalue
            return rowValue.toLowerCase().indexOf(filterValue.toLowerCase()) > -1;
        }
    }
};      

你把 filters.setLocal(true);filters.initPlugin(grid); 放上了吗?

这是我尝试并运行的代码:

GridFilters<MyRow> filters = new GridFilters<MyRow>();

filters.initPlugin(grid);

StringFilter<MyRow> filter = new StringFilter<MyRow>(nameValueProvider) {
  @Override
  protected boolean validateModel(MyRow model) {
    Window.alert("Hello");
    return super.validateModel(model);
  }
};

filters.addFilter(filter);
filters.setLocal(true);